Passing class objects between JS and server in Ajax

Source: Internet
Author: User
I found a write problem when I wrote an Ajax file today. I will share the following with you. To make JS object-oriented, but without defining the class structure, I defined an Ajax method on the server side and returned an empty object, such as m_res.
Then, after JS obtains this empty object through Ajax requests, it repeatedly uses this object structure using the clone method.
However, after the object value is filled up, it is found that the call fails because I have several datetime fields in this object. If these fields are not assigned a date object in JS, this method cannot be found on the server side (in fact, the object conversion fails ). So I will use m_res.createdate = new date ("2009/01/01 ");
Haha, the problem is solved, and there is no problem with Ajax calls.
In fact, this Ajax cannot automatically convert the string to datetime.

In addition, ajaxpro needs to register the Cs on this page in the onload event of the pageCodeClass. This is too troublesome.
I have registered the onload event in each page's base class (pagebase). For example:
Protected override void onload (eventargs E)
{
Ajaxpro. Utility. registertypeforajax (this. GetType (), this. Page );
Base. onload (E );
}

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.