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:
- Ie11 reports an error unhandled promise rejection typeerror: the object does not support
- Vue project reports an error on ie11 white screen. Script1002: syntax error
- Spock + powermock simulation static method reports an error java.lang.classcastexception
- Hadoop reports an error. Cannot access scala.serializable and python MapReduce reports an error
- The echots in Vue reports an error. After obtaining the DOM element, the chart can be displayed. The console still reports an error
- The file server reports an error of 413, and the file uploaded by nginx reports an error of 413 request entity too large
- Lamdba in the studio part reports an error. Observe lamdba reports an error but can run
- When websocket transmits JSON text, the parse method reports an error
- Vue agent reports an Error 404 nginx configuration method
- Ie8.0 reports Oracle error 1403 error after logging into Oracle EBS
- The idea code pushes to GitHub and reports an error fatal: unable to access
- The Vue parent component uses ref to call the sub component method and reports an error
- C ා programming encountered an object reference is required for the non-static field, method, or property error
- QT + MySQL generates an EXE file and reports an error “driver not loaded”. Solution steps
- Error in created hook: “referenceerror:” promise “undefined” Vue cli project Google is right, ie reported an error, “promise” undefined“
- Vue console reports an error duplicate keys detected: ‘XXXX’. This may cause an update error. Solution
- SSM project controller layer calls static method to report an error
- The C language qsort() function reports an error for overflow of – 2147483648 and 2147483648
- Vue install reports an error operation not allowed
- Android reports failed linking file resources