MVC 4.0 ajax.beginform return JavaScript Object not successful

Source: Internet
Author: User

Due to the compatibility of JS version, In VS, if the Jquery.unobtrusive-ajax.js version is not updated with NuGet, then the jquery version should only be limited to 1.7-1.8, if the reference 2.1, then Microsoft itself encapsulated a set of Ajax can not be used, so, everyone in the use of ajax.b Eginform, if you encounter some problems, may wish to try to drop the version of jquery, perhaps your problem will be solved;

One: The difference between jquery.unobtrusive-ajax.js and MicrosoftAjax.js,microsoftmvcajax.js

In MVC 1, version 2, they use their Ajax class libraries to implement AJAX requests, and the corresponding JS file is Microsoftajax.js,microsoftmvcajax.js
But programmers prefer jquery, "write less, does more", and Microsoft realizes it, slowly accepting jquery after soft, and then having a jquery.unobtrusive-ajax.js;

For MicrosoftAjax.js andmicrosoftmvcajax.js to work properly, you must add client side validation and unobtrusive in Web. config JavaScript two configurations
<add key= "clientvalidationenabled" value= "true"/>
<add key= "unobtrusivejavascriptenabled" value= "true"/>

, only at this time, the previous Ajax.beginform query to the backend function to follow your wishes.

However, if you want to use Jquery.unobtrusive-ajax.js (more lightweight), you can either set the true to false directly or delete the two configurations.

The above refers to two different JS files, you should pay attention to the JS version of the problem, because Microsoft out of these two sets of JS file is still very early, especially MicrosoftAjax.js,microsoftmvcajax.js These two JS files, If you have not been able to always lower the JS version, all the way to the line on it!

Two: The difference between content and JavaScript

Content is a string that is returned and then automatically parsed into a htmlstring in the foreground.

And JavaScript is to return a JS code, and then in the foreground will be automatically inserted into the JS script to execute. But JavaScript can do, the content can do, just the content of the string to change it, such as:

Return JavaScript ("alert (' Haha! ')");

Return Content ("<script type= ' text/javascript ' >alert (' Haha! ');</script> ")

The above two effects are the same!

So everyone properly consider their own coding appropriate style;

Next, let me steal a picture to explain the relationship.

MVC 4.0 ajax.beginform return JavaScript Object not successful

Related Article

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.