Note that there are some explanatory texts on larger screens.

plurals
  1. POAjax call to aspx page JQuery JSON
    primarykey
    data
    text
    <p>I ‘m trying to make an Ajax call to an aspx page On the server side request comes as "object object" and I cannot serialize it getting “not a JSON primitive.. ” it works however when instead of json object I pass json string .... Problem is that on a client side I’m using a json object that I have to convert to string before sending. I tried using function JSONToString() from json.org but this throws an error when I add jquery library. Does anybody know how it should be done I would much appreciate any help. </p> <p>add "JQuery/jquery-1.3.2.js" </p> <p>add "js/json.js"</p> <pre><code>&lt;script type="text/javascript"&gt; function callAjax() { var myjson = { document: { manufacture: { item: ['Alfa Romeo']}} } $.ajax({ url: 'jsonresponse.aspx', type: 'POST', //contentType: "application/json; charset=utf-8", data: myjson.toJSONString(), // throws an error in json libary // return JSON.parse(this, filter); //.. Microsoft JScript compilation error: Syntax error //data: myjson, can't serialize on the server request comes as object object //data:{ document: { manufacture: { item: ['Alfa Romeo']}} }, works but I need something to convert object to a string as it is much bigger then the one in example timeout: 1000000, dataType: "json", error: function() { alert("error"); }, success: function(myResult) { //alert(myResult); } }); } </code></pre> <p><br> jsonresponse.aspx</p> <pre><code> XmlDocument myxml = new XmlDocument(); StreamReader reader = new StreamReader(Page.Request.InputStream); string test; test = reader.ReadToEnd(); JavaScriptSerializer jss = new JavaScriptSerializer(); myxml = jss.Deserialize&lt;XmlDocument&gt;(test); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    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