0

I've continued to get a "not well formed" error when processing the response to this request.

function getFilterValues()
{
   $.get("/get_IrTempFilt?id=" + Math.random(),function(responseText,status){
      var splitstring = responseText.split("~");
      document.getElementById("FilterOn").innerHTML =  "<div>" + splitstring[0] + "</div>";
      document.getElementById("currentVal").innerHTML ="<div>" + splitstring[1] + "</div>";
      document.getElementById("value0out").innerHTML = "<div>" + splitstring[2] + "</div>";
      document.getElementById("value1out").innerHTML = "<div>" + splitstring[3] + "</div>";
   },"text");
}

The response is plain text which looks like this:

false~0~0~0

I took a hint from this question, which clued me in to specifying the dataType, and was able to figure out the syntax specific to $.get() from w3schools but the problem remains. Perhaps there is some nuance specific to this scenario that I have not figured out.

Community
  • 1
  • 1
2NinerRomeo
  • 2,687
  • 4
  • 29
  • 35
  • Perhaps you are having the same problem as the person asking this question. http://stackoverflow.com/questions/1828228/why-does-jquery-insist-my-plain-text-is-not-well-formed. If you are running on a web server a simple solution would be to change your sever response to be valid json. {result : 'false~0~0~0'} – Gordon Bockus Sep 30 '14 at 18:08
  • Attempted formatting as json as suggested, changing the dataType filed to "json". The browser continues to complain, although it seems to have stripped off the extra formatting, leaving me with the original "false~0~0", before complaining. – 2NinerRomeo Sep 30 '14 at 19:16
  • I thought it had stripped off the extra formatting at first, but subsequent tests showed the full json formatted return:"{result: 'false~0~0~0'}", still with the "not well-formed" complaint. – 2NinerRomeo Sep 30 '14 at 19:24
  • For well formed Jason you would need the server to return {"result": "false~0~0~0"}. Run JSON.stringify against the value to see the string version – Gordon Bockus Oct 01 '14 at 13:39

0 Answers0