jquery - JQqery ajax call with parameter not working -


i made jquery ajax call calling static page method. working fine wihtout parameter. if put parameter not call page method. have below code.

javascript

        $.ajax({         type: 'post',         url: 'itemmaster.aspx/uploadfile',         contenttype: 'application/json; charset=utf-8',         data: {'path':'mydata'},         datatype: 'json',         success: function (msg) {             alert(msg.d);         }     }); 

page method

    [webmethod]     public static string uploadfile(string path)     {         return "success";     } 

is there datatype mismatching happened?. warm google time without success. please help..

your data object needs json string. try

var datatosend = json.stringify({'path':'mydata'});  $.ajax({     type: 'post',     url: 'itemmaster.aspx/uploadfile',     contenttype: 'application/json; charset=utf-8',     data: datatosend,     datatype: 'json',     success: function (msg) {         alert(msg.d);     } }); 

be sure include json.js if supporting older browsers.


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -