Json request with jQuery don't be evil'
Thu, 10/08/2009 - 10:20
Jesus how complex can it be! For our hyves/facebook gadget we needed to fetch some json from our website. After getting the < don't be evil' > message for a while we figured it out.
If this is your call: function getJson() {
$.getJSON(http://www.yourdomain.com/hyvesapp/json?callback=?, function(data){
alert("got here"+data.name);
});
}
In your code you have to do some things to get this working, jQuery adds a function name to the ? at the end (see the manual) so you need to readout the callback GET param in your script to get it to work.
This is the function is used:
function hyvesappCreatejson(){
header("Content-Type: application/json;");
$obj = new stdClass;
$obj->name = "yourname";
$obj->url = "www.gijs.com";
echo $_GET['callback'].'('.json_encode($obj).')';exit;
}
Hope this helps.
Security CCTV Camera | SEO Service India| SEO Friendly Directory | Leather Bags | Navi Mumbai Real Estate
Generic Viagra | Cheap Generic Viagra | Generic Levitra | Generic Viagra | Cheap Generic Viagra | Kamagra | Cheap Generic Viagra | Finpecia | Penegra | Generic Viagra and Kamagra | Generic Viagra
Post new comment