1. The code that is having the problem
/*** * Request static HTML template * @param URL * @param $jqueryDiv: One of the four main div * @param templatehandle: Custom, used to use dot JS template function * @param callback: After implementing the template, the binding event * @param the return data of Templatedata:cia */Ajaxhtml: function (URL, $jqueryDiv, Templatehandle, Callback, TemplateData) {Xhr.ajaxhtmlcommon (URL, $jqueryDiv,NULL, Templatehandle, Callback, TemplateData); },/*** * Ajax request static HTML file * @param URL * @param $jqueryDiv * @param data * @param callback: callback function, upd After the Atehtml method executes * /Ajaxhtmlcommon: function (URL, $jqueryDiv, RequestData, Templatehandle, Callback, TemplateData) { varArgument_length =arguments. length;varIshascallback = (Argument_length >4&& Callback &&typeofcallback = = =' function ');varOptions22 = {Url:url, type:"GET", timeout:18000, DataType:' HTML ', Success: function (HTML) {Updatehtml ($jqueryDiv, HTML, Templatehandle, TemplateData);/* var $formInput = jqueryobj.find (' Textarea:first ');//Allow textarea in subcontent to focus if ($formInput. length ! = 0) {//First determine if you can get to textarea $formInput. Get (0). focus (); }*/ if(Ishascallback) {Callback ($JQUERYDIV, HTML); }}, Error: function (er) { if(Er.statustext = =' Timeout ') {updatehtml ($jqueryDiv,"<div style= ' color:red ' > Connection server timed out! </div> "); }Else{varErrorMessage2;if(er.responsetext) {errorMessage2 = Er.responsetext; }Else{errorMessage2 = Er.statustext; } console.log (' ERROR: '+ ErrorMessage2); Updatehtml ($jqueryDiv, ErrorMessage2, Templatehandle, TemplateData); }if(Ishascallback) {Callback ($JQUERYDIV, er); } } };if(Argument_length >2&& RequestData! =NULL&& RequestData! =undefined) {options22.data = RequestData; Options22.type ="POST"; } $.ajax (OPTIONS22); }
Browser version: IE8
Get HTML template times wrong:
varfunction () { xhr.ajaxHtml(‘cross_domain.html‘, $(‘#crossDiv‘nullnullnull); }
Error message: TypeError denied access
2. Workaround:
(1) Increase in the head of JS file:
true;
(2) HTML file introduced JQuery.XDomainRequest.js
<!--[if IE 8]> <script type="text/javascript" src="jQuery.XDomainRequest.js"></script> <![endif]-->
(3) Add static HTML template before:
< meta http-equiv= "Access-control-allow-origin" content= "*" >
Attention:
(1) The static HTML template should be added before, indicating that the server side supports cross-domain.
(2) Only IE8 have cross-domain access denied, so when introducing a third-party JS file, use <!–[if IE 8]>
(3) Jquery-1.11.1.js and above do not support IE8
JQuery.XDomainRequest.js See annex
Reference: Https://github.com/MoonScript/jQuery-ajaxTransport-XDomainRequest
Http://stackoverflow.com/questions/10232017/ie9-jquery-ajax-with-cors-returns-access-is-denied
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
IE8 jquery ajax get static resources error TypeError deny access