Click here to Skip to main content
15,881,248 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have the following code, how can I get the src of the json data to change when the user submits a form? I need to change the 'text=' part of the src, to what the user has entered in the form, without a page reload.
<script>
function myFunction(arr) {
	
        var i =0;
        document.getElementById("fullname").innerHTML =  arr[i].FULLNAME ;
        document.getElementById("motto").innerHTML =  "'"+arr[i].MOTTO+"'";
        ...
        ...
        document.getElementById("firstlog").innerHTML = arr[i].FIRSTLOGIN;
        document.getElementById("lastact").innerHTML = arr[i].LASTACTIVITY;
		}
});
</script>
<script src="http://nsdata.a78.org/m/json.php?text=southern_ageena&type=json"></script>
Posted
Updated 17-Jan-15 9:47am
v2

1 solution

JQuery's parseJSON[^] for example simply evaluates the json object to javascript object. So all you have to do is make an ajax call to that url, and pass the result to this method.
Or, there is getJSON[^]...
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900