javascript - Bad format in JSON response AJAX -
i have follow code, it's call web service in other pc server. data parameters ok.
"{ controlid: 'zasociated_26037', taskid: 1495613, userid: 166396, tbodyid: ''}"
$.ajax({ type: "post", cache: false, datatype: "json", contenttype: "application/json; charset=utf-8", data: "{ controlid: '" + controlid + "', taskid: " + taskid + ", userid: " + userid + ", tbodyid: '" + $(tbody).attr("id") + "'}", url: getwspath() + "/getzasociatedresults", // cargar aqui la direccion del webserivce success: function (data) { if (data != null && data.d != "[]") loadasociatedtable(controlid, data.d); $("#loadingimg" + controlid).remove(); }, error: function (xhr, ajaxoptions, thrownerror) { $("#loadingimg" + controlid).remove(); alert("error al obtener los datos: " +thrownerror + "\ncodigo de error: " +xhr.status); } });
the error is, when have data.d result of ws, json add adicionals "\" chars in string:
the begin of response: [{\"nombre del documento\":\"indemnizacion/factura. 22076 - proveedor - sin: 38653 global: no\",\"estado\":\"pago finalizado\",
i try replace "\" null string doesnt work
this ajax when success call loadasociatedtable function , do:
(var = 0; < $.parsejson(data).length;i++){
and have error in $.parsejson(data).length because don't converter string object.
i checked in chrome , json ok, without bar "\", , recognize object, problem in ie v.11 only.
can post complete json me analyze in meanwhile try this
using eval on data.d eval("{"+data.d+"}");
or json.parse(data.d)
try validate json here http://jsonlint.com/
Comments
Post a Comment