Note that there are some explanatory texts on larger screens.

plurals
  1. POMy json string is being returned in an incorrect format, can I use $.ajax to get the data anyway?
    primarykey
    data
    text
    <p>EDIT: It seems that the formatting of the json string is not the problem. Instead I'm not seeing the json string in the Firebug response section and yet ajax error handlers aren't being thrown.</p> <p>Hi!</p> <p>So I've got a web service setup so that it will return a very simple json string: </p> <pre><code>{"A":1,"Total":1} </code></pre> <p>After reading several threads on stackoverflow and even on the jquery documentation page for $.ajax, I learned that the correct formatting for the json string is to have each value within double quotes as well.</p> <pre><code>{"A":"1","Total":"1"} </code></pre> <p>I'm assuming that is why my jquery ajax is not working:</p> <pre><code>$.ajax({ type: "GET", url: "http://test/testServices/InfoService.svc/GetInfoStats?pId=76&amp;mId=2117", dataType: "json", error: function(xml,txtStatus, errorThrown){ alert(xml + " " + txtStatus + " " + errorThrown); }, success: function (msg, test) { alert("JSON DATA LOADED! " + msg); $(".MainContainerBottom").html(msg); } }); $('.log').ajaxError(function () { $(this).text('Triggered ajaxError handler.'); }); </code></pre> <p>Firebug's Console window is telling me that the GET was "200 OK 398ms" consistently and if I check test variable it returns success as well. msn returns null though! The Params and the Headers section of Firebug also looks good but the Response section is empty.</p> <p>I was also messing around with the dataType of the $.ajax and had it as jsonp at first and firebug returned an error stating </p> <pre><code>Invalid Label {"A":1,"Total":1} </code></pre> <p>So I know the information is coming back correctly but I can't access it. I'm assuming it's because of the formatting issue I began this post with. Is that correct?</p> <p>Assuming I don't have the ability to modify the web service myself, what can I do to get the json data out and into my script?</p> <p>Thank you very much! &lt;3 John </p> <p>EDIT: For Guffa</p> <pre><code>Response Headers Content-Length 39 Content-Type application/json; charset=utf-8 Server Microsoft-IIS/7.5 X-Powered-By ASP.NET Date Fri, 12 Nov 2010 21:58:57 GMT Request Headers Host test User-Agent Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.9) Gecko/20100824 Firefox/3.6.9 Accept application/json, text/javascript, */* Accept-Language en-us,en;q=0.5 Accept-Encoding gzip,deflate Accept-Charset ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive 115 Connection keep-alive </code></pre> <p>Final Edit: I spoke to the guy who setup the web service for us and apparently there was some special restrictions on the information being sent back. He setup some permissions for our application to access the data and it worked flawlessly.</p> <p>Thanks to everyone for your help! I'm really surprised by the amount of people who responded and tried to help me out. I'll definitely be sticking around the stackoverflow community now and hopefully one day I can help out others as well :)</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