i making web application requires downloading of many json files , store them in localstorage once in while( maybe month). using parse.com backend service. hosted json on parse.
my code is:
<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title></title> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> <script type="text/javascript" src="http://www.parsecdn.com/js/parse-1.2.18.min.js"></script> <script type="text/javascript"> parse.initialize("my_app_key", "my_js_key"); </script> <script> $.getjson( "http://myappname.parseapp.com/1111.json", function( data ) { var items = []; $.each( data, function( key, val ) { items.push( "<li id='" + key + "'>" + val + "</li>" ); }); $( "<ul/>", { "class": "my-new-list", html: items.join( "" ) }).appendto( "body" ); }); </script> </head> <body> </body> </html> i following error:
cross origin request blocked: access-control-allow-origin header missing.
but when open in browser, opens fine.
why doesn't work? there possible solution it?
thanks.
otherwise can add callback=? url using below jsonp type of data:
$.getjson( "http://myappname.parseapp.com/1111.json?callback=?", function( data ) { var items = []; $.each( data, function( key, val ) { items.push( "<li id='" + key + "'>" + val + "</li>" ); }); $( "<ul/>", { "class": "my-new-list", html: items.join( "" ) }).appendto( "body" ); }); update
$.ajax({ url:'http://myappname.parseapp.com/1111.json', datatype:'jsonp', crossdomain:true, success:function( data ) { var items = []; $.each( data, function( key, val ) { items.push( "<li id='" + key + "'>" + val + "</li>" ); }); $( "<ul/>", { "class": "my-new-list", html: items.join( "" ) }).appendto( "body" ); }, error:function(jqxhr,responsetext,status){ console.log(jqxhr); } }); this how in ajax. if face issue check console logged
Comments
Post a Comment