I'm not very experienced in C#/.NET [WebMethod] (note: I am on Mono) and I wonder how could I use the JQuery.form plutin. I have a Service.asmx and Service.asmx.cs with methods I call with standard jQuery AJAX call.
I开发者_运维百科n the form "action" attribute I put link to the Service (/blah/blah/Service.asmx/myMethod
). Which firm and/or attributes must have the 'myMethod' to accept the POST message?
Thank you
It really doesn't matter that you are using [WebMethod] in this case. You just need to know how to format your HTML form. Here's what it should look like:
<form id="myForm" action="/blah/blah/Service.asmx/myMethod/" method="post">
....
</form>
To setup the jquery, you just have to specify what you're returning. Here's the general form, which you can customize to your needs.
$("#myForm").ajaxForm({
dataType: 'json',
success: function (responseText, statusText) {
...
},
beforeSubmit: function (formData, jqForm, options) {
....
}
});
The options for dataType is json, xml, script or none. In the success function, that is where you handle the returned ajax data.
Hope that helps.
精彩评论