Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to send json data to asmx (from aspx) using jquery?
    primarykey
    data
    text
    <p>I built contact form in aspx 3.5 and I'm using jQuery to send it to web service (asmx). <br><br> The web service need to return success or error code. The problem is that at the web method I get only single value and not array. I'm kind of new in ajax and I tried a lot of solutions but without any results. Please if you can only explain me the principle of what to do it also be good.</p> <p>This is the client side:</p> <pre><code>$(document).ready(function() { $("#submit").click(function(event) { $.ajax ({ type: "POST", url: "RVContactFormMailer.asmx/HelloToYou", data: "{'name': '" + $('#name').val() + "', 'company':'" + $('#company').val() + "', 'phone':'" + $('#phone').val() + "', 'email':'" + $('#email').val() + "', 'questions':'" + $('#questions').val() + "'}" , contentType: "application/json; charset=utf-8", dataType: "json", success: function(msg) { AjaxSucceeded(msg); }, error: AjaxFailed }); }); </code></pre> <p>In firebug its sends correctly:</p> <pre><code>{'name': 'jhon', 'company':'example', 'phone':'123', 'email':'jhon@jhon.com', 'questions':'hello'} </code></pre> <p>The asmx code is (please ignore the names, its example:</p> <pre><code> [WebService(Namespace = "http://tempuri.org/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] [ScriptService] // To allow this Web Service to be called from script, using ASP.NET AJAX or JQuery. [ToolboxItem(false)] public class RVContactFormMailer : System.Web.Services.WebService { [WebMethod] [ScriptMethod(ResponseFormat = ResponseFormat.Json)] public string HelloToYou(string name) { return "Hello " + name; } } </code></pre> <p>When I debug I see that the input parameter "name" contains only one string - I don't know how to get the full json string that I send to the service and contains all the form data - I want to desirialize it to string array or something like, and process it. how can I do that?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload