Wednesday 5 June 2013

ajax call in jquery asp.net

Ajax call in jquery use
  • url
    Type: String
    A string containing the URL to which the request is sent.
  • async (default: true)
    Type: Boolean
    By default, all requests are sent asynchronously (i.e. this is set to true by default). If you need synchronous requests, set this option to false. Cross-domain requests and dataType: "jsonp" requests do not support synchronous operation. Note that synchronous requests may temporarily lock the browser, disabling any actions while the request is active. 
  • cache (default: true, false for dataType 'script' and 'jsonp')
    Type: Boolean
    If set to false, it will force requested pages not to be cached by the browser. 
  • contentType (default: 'application/x-www-form-urlencoded; charset=UTF-8')
    Type: String
    When sending data to the server, use this content type. Default is "application/x-www-form-urlencoded; charset=UTF-8", which is fine for most cases. 


$.ajax({
            type: "POST",
            url: "../Pagename.aspx/user",
            data: JSON.stringify({ userId: 1, status: 1 }),
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            async: false,
            success: function (data) {
                                //do logic
                           }
        });

No comments:

Post a Comment