Monday, April 21, 2014

[jQuery][Solved] Force print json content in plain text

Finally I got the nice answer by Rocket Hazmat , he mentioned the callback to $.getJSON in jQuery actually has 3 parameters:  data, textStatus and jqXHR.
The jqXHR object contains a responseText property that contains the raw JSON string.

And there is the example:
var json = $.getJSON("test.json",
   function(response, status, jqXHR){           // do stuff           console.log(jqXHR.responseText);       });

And I used the answer to apply on my case to print json object in plain text when clicking a submit button named with id “submit”:
$("#submit").one("click", function () {    url = 'http://abc.com/cms/sliders';    $.post(url, $('#fb_form').serialize(), function(response, status, jqXHR){        alert(jqXHR.responseText);    }, 'json');});

Hope this short article can help you.
To know more, please visit the link provoded below:

Reference:

No comments :

Post a Comment