html - JavaScript IE read data from json file Access Denied -
i have problem code on ie browser , chrome in firefox works done.
var currentpage = 1; var max = 0; var mylist = []; var links = []; $.ajax({ cache: false, type : 'get', crossdomain: true, contenttype: "application/json", datatype : 'json', url: 'list.json', success : function(data) { $.each(data, function(key, value){ if(window.location.href == value.link){ document.getelementbyid("count").innerhtml = value.page; currentpage = value.page; } document.getelementbyid("countall").innerhtml = value.page; mylist.push("<li><a href=" + value.link +"><b>"+value.page+"</b></a></li>"); max = value.page; links.push(value.link); }) $('.pagination').html(mylist.join('')); if ( currentpage == 0){ document.getelementbyid("leftarrow").innerhtml = "❰" document.getelementbyid("rightarrow").innerhtml = "<a href="+links[currentpage]+">❱</a>"; } else if (currentpage == max){ document.getelementbyid("leftarrow").innerhtml = "<a href="+links[currentpage-2]+">❰</a>"; document.getelementbyid("rightarrow").innerhtml = "❱" } else { document.getelementbyid("leftarrow").innerhtml = "<a href="+links[currentpage-2]+">❰</a>"; document.getelementbyid("rightarrow").innerhtml = "<a href="+links[currentpage]+">❱</a>"; } } }).error(function(jqxhr, textstatus, errorthrown) { alert(errorthrown); });
in ie have err: "access denied", know problem? reply.
why use crossdomain attribute since url accessing local?
$.ajax({ cache: false, type : 'get', crossdomain: true // <--- cross domain
in case need cross domain calls maybe should try jquery plugin ie:
https://github.com/moonscript/jquery-ajaxtransport-xdomainrequest
Comments
Post a Comment