It’s been a long time since I’ve done any jQuery/js stuff, and silly $.get() is giving me problems. I’m in a purely testing stage, and just want to use $.get to return a json-encoded string.
This is what I would like to use:
<script>
function send_address(){
$.get("tester3.php", function(data){
alert("Data Loaded: " + data);
});
}
</script>
However, the only way I can get a response is by using this (which executes out of order, but I understand that is a result of an asynchronous call, and isn’t the issue):
<script>
function send_address(){
$.get("tester3.php", function(data){
alert("Data Loaded: " + data);
});
alert('here');
}
</script>
I just want to send a get request to “tester3.php” and see the returned string without having to put in the alert.
Thanks, and happy holidays!
UPDATED:
Here’s the html that calls the function:
<form id="maps_check" class="niceform">
<fieldset>
<input type="submit" value="Submit" onclick="send_address()"/>
</fieldset>
</form>
If you are calling the
send_addresson a click or submit event I think you should try to returnfalse.You could also cancel the default action by using
preventDefault()like this: