/ Published in: PHP
If not have access to edit json, setting url possible is:
url: 'http://graph.facebook.com/4/?callback=getDatosUsuario'
url: 'http://graph.facebook.com/4/?callback=getDatosUsuario'
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
HTML domain1.com <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>JsonCrossDomain</title> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js" type="text/javascript"></script> </head> <body> <div id="container"></div> <script> $(document).ready( function(){ jQuery.ajax({ url: 'http://domain2.com/test.json', dataType: "script", type: "GET", cache: false, callback: null, data: null }); } ); function getDatosUsuario(datos){ if( confirm('¿Querés ver a quién encontré?') )alert(datos.name); else alert('jodete!'); } </script> </body> </html> JSON, domain2.com getDatosUsuario({ "id": "4", "name": "Mark Zuckerberg", "first_name": "Mark", "last_name": "Zuckerberg", "link": "https://www.facebook.com/zuck", "username": "zuck", "gender": "male", "locale": "en_US" });