Processing encoded json response from ajax request in jquery -


I am trying to make an AJAX request using jquery:

  $ . Ajax ({Url: "/ src / ax_query_places", data type: "Jason", data: {query: value}, success: function (response) {warning ("success");}, failure: function () {warning ('Get airport');}, error: work () {alert ('error');}});  

I am json encoding on the server side: JSN data is received on the response:

  {"places": [{"name": "new" X20 Orlense, \ x20US \ x20 \ x28 New \ x20Lakefront \ x20 \ x2D \ x20NEW \ x29 "," Code ":" New "}, {" Name ":" New \ x20 Beedford, \ x20US \ x20 \ x28 All \ X20d \ x20WB \ x2D \ x20EWB \ x29 "," code ":" EWB "}}  

But I am getting the error every time Please suggest that any error in syntax is. Or should I parse the encoded response?

In addition, if I remove Jason's encoding on the server side, then everything works fine.

You might want to keep a list of "places" and "location" class in which two Properties will be "name" and "code".

In that case, with the first two places, make a class named "place" which should be "name" and "code" (name must be)

from the client side, Data: {query: JSON.stringify (value)}

Hold string value as the parameter in server side. Therefore, your method will be recession -

  public YourReturnType YourMethodName (string query)  

Inside that, use the following code -

< Pre> var javascriptSerializer = new JavaScriptSerializer (); Var value = javaScriptSerializer.Deserialize & lt; List & lt; Places & gt; & Gt; (Query);

You will be serialized JSON in prices.

Hope it helps!


Comments

Popular posts from this blog

Member with no value in F# -

java - Joda Time Interval Not returning what I expect -

c# - Showing a SelectedItem's Property -