Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I figured it out. </p> <p>I didn't want to use the JavascriptSerializer class because it dumped my nested list so I forced it to pass me the object as a string and then I manually deserialized it. I also kept getting "no parameterless constructor defined for type of u0027system.string u0027"</p> <p>Remember that U0027 is an apostrophe so the runtime might be thinking that there is an actual type named "System.string" and not System.string. My problem was - I wasn't correctly delimiting the parameters in the item below called data2. I had to put \' ticks \' around the key and the value.</p> <pre><code>function requestHtmlFromServer(mqvmJSON) { var mqvmstring = JSON.stringify(mqvmJSON); var data2 = "{\'mqvm\':\'" + mqvmstring + "\' }"; \\&lt;--the problem $.ajax({ type: "POST", dataType: "json", contentType: "application/json; charset=utf-8", data: data2, url: "MedicalInformation.aspx/CreateResponseReview", success: function(data) { alert(data.d); }, error: function(jqXHR, textStatus, errorThrown) { alert(jqXHR.responseText + ' ' + errorThrown); } }); } [ScriptMethod(ResponseFormat = ResponseFormat.Json)] [WebMethod] public static string CreateResponseReview(string mqvm) { string noNewLines = mqvm.Replace("\n", ""); View viewModel = ToObjectFromJSON&lt;View&gt;(noNewLines); //do my other stuff here return "Success"; } public static T ToObjectFromJSON&lt;T&gt;(string jsonString) { var serializer = new DataContractJsonSerializer(typeof(T)); var memoryStream = new MemoryStream(Encoding.Unicode.GetBytes(jsonString)); var newObject = (T)serializer.ReadObject(memoryStream); memoryStream.Close(); return newObject; } </code></pre>
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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