asp.net - Unable to call server side function using jquery -


i have following code in jquery

            $('#btnsubmit').click(function () {             $.ajax({                 type: "post",                 url: "appointment.aspx/saveappointment",                 data: "{firstname:'" + firstname + "'}",                 contenttype: "application/json; charset=utf-8",                 datatype: "json",                 success: function (msg) {                     alert(1);                     // interesting here.                 }             });         }); 

i calling function in vb.net

<webmethod()> _ public shared function saveappointment(byval firstname string) boolean      dim checkval = globalclass.firstname     try      catch ex exception         throw ex     end try     return true end function 

end class

it seems work without parameters. there no call if parameters provided. referred seem work

calling asp.net server side method via jquery

thanks!

https://api.jquery.com/jquery.ajax/

to post data object:

data type: plainobject or string data sent server. converted query string, if not string. it's appended url get-requests. see processdata option prevent automatic processing. object must key/value pairs. if value array, jquery serializes multiple values same key based on value of traditional setting (described below).

data: {firstname: firstname}  

or

data: {firstname: firstname}  // in case want assign "firstname" string value        data posting. 

considering firstname on right side defined variable in javascript , while firstname on left side name use in other side script ( php , vb.net ... etc )


Comments

Popular posts from this blog

jQuery Mobile app not scrolling in Firefox -

c++ - How to add Crypto++ library to Qt project -

php array slice every 2th rule -