How to report an error using the load method after jquery overrides ajax and submits and judges permissions _ jquery

Source: Internet
Author: User
This article mainly introduces jquery's information about how to use the load method to report errors after rewriting ajax and submitting and determining permissions. If you need more information, please refer to the following, paste the Code directly.

JQuery (function ($) {// back up jquery's ajax method var _ ajax =$. ajax; // rewrite the ajax method. First, judge that the success function is being executed during login $. ajax = function (opt) {var _ success = opt & opt. success | function (a, B) {}; var _ opt = $. extend (opt, {success: function (data, textStatus) {// if the background redirects the request to the logon page, the source code of the logon page is stored in data, here we need to find the evidence that data is the logon page (TAG) if (typeof data) = 'string' & data. indexOf ('shangjiaajaxextend ')! =-1) {window. location. href = 'HTTP: // '+ window. location. host + '/S/BusiLogin/Index'; return;} else {_ success (data, textStatus );}}}); return _ ajax (_ opt );};});

Rewrite principle: Because the closure function is loaded before the script on the page, you can directly rewrite $. ajax method here.

The key point is that the red part of the content must be retrun. Otherwise, the error "Uncaught TypeError: Cannot call method 'done' of undefined" is returned when loading the page using the load method ."

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.