HTML method IE8 reports an error, IE8 jQuery Ajax obtains static resources reports an error, typeerror denies access

Problem code/* * * request static HTML template * @ param URL * @ param $jquerydiv: one of the four main div * @ param templatehandle: custom, used to use dot JS template function *@

1. Problem code

/***

*Request static HTML template

* @param url

*@ param $jquerydiv: one of the four major divs

*@ param templatehandle: custom, used to use dot JS template function

*@ param callback: used to bind events after template implementation

*@ param templatedata: return data of CIA

*/

ajaxHtml: function (url, $jqueryDiv, templateHandle, callback, templateData) {

xhr.ajaxHtmlCommon(url, $jqueryDiv, null, templateHandle, callback, templateData);

},

/***

*Ajax requests static HTML files

* @param url

* @param $jqueryDiv

* @param data

*@ param callback: the callback function is executed after the updatehtml method

*/

ajaxHtmlCommon: argument_ length = arguments.length;

var isHasCallback = (argument_ length > 4 && amp; callback && amp; typeof callback === ‘function’);

var options22 = {

url: url,

type: “GET”,

timeout: 18000,

dataType: ‘html’,

success: function (html) {

updateHtml($jqueryDiv, html, templateHandle, templateData);

/* var $formInput = jqueryObj.find(‘textarea:first’);// Focus the textarea in subcontent

if ($formInput.length != 0) {//judge whether the textarea can be obtained first

$formInput.get(0).focus();

}*/

if (isHasCallback) {

callback($jqueryDiv, html);

}

},

error: (er.statusText == ‘timeout’) {

updateHtml($jqueryDiv, ”

Connection to server timeout!

“);

} else {

var errorMessage2;

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 && amp; requestData != null && amp; requestData != undefined) {

options22.data = requestData;

options22.type = “POST”;

}

$.ajax(options22);

}

Browser version: IE8

Error in getting HTML template:

var ajaxHtml4IE8 = function () {

xhr.ajaxHtml(‘cross_ domain.html’, $(‘#crossDiv’), null, null, null);

}

Error message: access denied by typeerror

2. Solutions:

(1) In the header of JS file, add:

jQuery.support.cors = true;

(2) Introduce jquery.xdomainrequest.js into HTML file

(3) Add in front of static HTML template:

< meta http-equiv=”Access-Control-Allow-Origin” content=”*”>

be careful:

(1) Static HTML template should be added before, indicating that the server supports cross domain

(2) Only IE8 has the problem of cross domain access denial, so when introducing a third-party JS file, you should use & lt;! –[ if IE 8]>

(3) Jquery-1.11.1.js and above does not support IE8

Jquery.xdomainrequest.js is attached

reference resources: https://github.com/MoonScript/jQuery-ajaxTransport-XDomainRequest ,

Read More: