jQuery('input').live('click',function(e){
$.getJSON(
"/json.php",
function(data){
the_name = data.name;
}
);
});
When we press , it should make a json query.
Bit it gives errors.
In Google Chrome console:
- Failed to load resource http://site.com/json.php
- Uncaught TypeError: Cannot read property 'name' of null
In Firefox console:
- GET http://site.com/json.php - is bolded with red color.
- data is null; the_name = data.name;
The strange is when I open http://site.com/json.php, browser gives me a normal json code like:
{"name":"Mary"}. It is encoded with php json_encode();
What is the problem?
site.com? You cannot make cross-domain ajax requests. en.wikipedia.org/wiki/Same_origin_policy