Note that there are some explanatory texts on larger screens.

plurals
  1. PODeserialize jQuery Serialized Form
    primarykey
    data
    text
    <p>I'm trying to pass form inputs into a WebMethod and doing something. I used <a href="http://api.jquery.com/serialize/" rel="noreferrer">jQuery Serilize</a>.</p> <pre><code>&lt;script type="text/javascript"&gt; $.fn.serializeNoViewState = function () { return this.find("input,textarea,select,hidden") .not("[type=hidden][name^=__]") .serialize(); } $(function () { $("#Button1").click(function (e) { var res = $("#myform").serializeNoViewState(); var jsonText = JSON.stringify({ bject: res }); $.ajax({ type: "POST", url: "Default.aspx/Test", data: jsonText, contentType: "application/json; charset=utf-8", dataType: "json", success: function (msg) { // alert("asd"); }, error: AjaxFailed }); }); }); function AjaxFailed(result) { alert("Failed"); } &lt;/script&gt; </code></pre> <p>in target WebMethod I want to Deserialize that object I passed.</p> <pre><code>[WebMethod()] public static bool test(string bject) { JavaScriptSerializer JsTool = new JavaScriptSerializer(); } </code></pre> <p>I Tried to use Javascriptserilizer Class. but I did not succeed. now how can I use this Object? I want to use this way for using jQuery AJAX simpler(For example passing form inputs to a WebService and inserting that in Database). Due the action I want to do is this way right ? Welcome your Suggestions , tips .</p> <h2>Update:</h2> <p>how can I map the Serialized JS object to my C# entity object? Is this way is good Way ? or there are better way exist ? if yes please give me some information</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.
    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