Microsoft's built-in Ajax requests and Microsoft's built-in Ajax requests

Source: Internet
Author: User
Tags fiddler2

Microsoft's built-in Ajax requests and Microsoft's built-in Ajax requests

Home Controller

Using System; using System. collections. generic; using System. linq; using System. web; using System. web. mvc; namespace MvcApplication1.Controllers {public class HomeController: Controller {// GET:/Home/public ActionResult Index () {return View ();} public ActionResult GetDate () {// Thread. the Sleep () method is used to Sleep the current thread for a certain period of time. The unit is millisecond 1000 milliseconds = 1 second System. threading. thread. sleep (1000); // delay the website by 1 second to view the effect of LoadingElementId = "loadingID" and return Content (DateTime. now. toString ();} public ActionResult MicrosoftAjax () {return View ();}}}

MicrosoftAjax. cshtml View

@ {Layout = null ;}<! DOCTYPE html> 1

.

2



3


4


5



"How can I clear the cache when mvc3 uses Microsoft's built-in ajax to load the branch view "?

We recommend that you do not use Microsoft products. It is easier to use jquery instead ~
 
The value of xmlhttpstatus in Ajax is 500

I:
HTTP Status Code = 500 indicates that your program has an error on the server (rather than the client ). because the http method you use is post, it is not recommended that you "directly open the request address to see if the request is running normally ":

We recommend that you install an HTTP debugging software called Fiddler www.fiddler2.com/fiddler2/

This software can detect all HTTP requests/Replies produced by your browser and their specific content.
Open the debugging options in Web. config. (otherwise, you cannot see the specific error information)
<CustomErrors mode = "Off"> </customErrors>
Then open the page and you will see a 500 request/reply. view the Response content to determine the specific error.

Firefox's Firebug plug-in can also achieve this. We recommend that you try it.
-----------------
II:
Cross-origin is simply the Domain Name of the page for your ajax request, which is different from the domain name requested by ajax. in this example, we can confirm that the error you encounter is not a cross-origin error. Because a cross-origin error is a client error, js will report an error. The request cannot be sent in the fundamental way and will not receive 500 server response.
-----------------
III:
We recommend that you use some class libraries for ajax, instead of writing XMLHTTP directly (of course, there is no way to reference it in special cases ). one advantage of this is that it saves time and effort to avoid writing code that has been debugged many times to determine whether there are no errors (for example, you don't have to worry about different browsers ); the second is to make your code clearer. You only need to write the functions you want, such as creating XMLHTTP. Let those JS class libraries do it.
Common JS class libraries include jQuery and Microsoft Ajax class libraries. We recommend jQuery to get started quickly.

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.