$r['zipCode'] = $_GET['zipCode'];
//really you should clean this
echo json_encode($r);
diafol
Keep Smiling
10,655 posts since Oct 2006
Reputation Points: 1,628
Solved Threads: 1,512
Skill Endorsements: 57
OK, just to test it:
PHP
echo "hello";
JS
$.ajax({
type: "GET",
url: "getCityAndState.php",
async: true,
data: {zipCode: data},
success: function(data){
alert("SUCCESS:" + data);
},
complete: function(data)
{
alert("No bueno");
}
});
diafol
Keep Smiling
10,655 posts since Oct 2006
Reputation Points: 1,628
Solved Threads: 1,512
Skill Endorsements: 57
It fire an alert() on this:
alert("JSON String:" + jsonString.zipCode);
So you've obviously got the jQuery library referenced properly and you are actually calling the function.
Try clearing the cache in your browser, and if you're using a templating engine, delete any tmp files. Try again.
If still no joy, have a look at the php file reference - is it valid? Does it need a prefix path like "/includes/..." ?
If still no joy...
function getCityAndState(data, location){
var request = $.ajax({
url: "getCityAndState.php",
type: "GET",
data: {zipCode : data},
dataType: "html",
success: function(transport){
alert("SUCCESS:" + transport);
}
});
}
And just echo some simple text in the php file. Just to see that it works for you.
diafol
Keep Smiling
10,655 posts since Oct 2006
Reputation Points: 1,628
Solved Threads: 1,512
Skill Endorsements: 57
OK, this is js - you may find it easier to post to the js forum.
diafol
Keep Smiling
10,655 posts since Oct 2006
Reputation Points: 1,628
Solved Threads: 1,512
Skill Endorsements: 57