I’m currently working on cross domain data transfer and I’ve hit a really big block, I’ve spent hours & hours trying to get this to work, it seems to be the correct way of doing it so any pointers would be greatly received.
I’m using jquery & the getJSON to return a id from a php page that json_encodes the data;
My jquery code is `
$.getJSON("http://www.icetrack.it/scripts/php/data/ipAddress.php",
{
location: locationVar,
user_key: user_key,
refer: refer,
title: title,
async:false,
dataType: 'json',
success: function(data) {
alert(data);
}
},"json");
which talks to a php page that outputs nothing other than,
echo json_encode(array("id"=>"$id")); ?>
This page outputs JSON as such
{"id":"198"}
Yet all my jquery will return is a undefined variable, where am I going wrong this is driving mad!
Thanks all!
You’re passing the wrong parameters to
$.getJSON()– many of the ones you’ve supplied only work for$.ajax().In particular, the
dataparameter for$.getJSON()is for CGI parameters to be sent to the server, not for arbirtrary$.ajax()parameters.Try this: