[jQuery] jsonp problems
[jQuery] jsonp problems
Hello,
I am having problems using jquery's cross domain json function.
I send a request like this:
var data = { 'data': '10' };
$j.ajax({
dataType: 'jsonp',
data: data,
url: 'http://another-domain/json-echo.php?jsoncallback=?',
success: function(json){
alert("received back: " + json);
}
});
and on the json-echo.php
$val = json_decode($_REQUEST['data'], true);
$output = json_encode($val);
echo $_REQUEST['jsoncallback'].'('.$output.')';
I get alert box with:
received back: 10
going any more complex with the data that I send always fails to
decode properly and i get a null back
so if set
data = {
'data':
{ 'url' : 'someurl' }
};
if fails... I've struggled with this all day trying all could think of
with no luck so far. Please help me get this working. :)
thank you
Slava