Parsing JSON with a jQuery ajax object using POST


It’s a bit of a head-scratcher at first, seeing as the jQuery docs mysteriously disavow a postJSON possibility, let alone a function, but it’s definitely doable. So here’s the glorious code:

function postjson(url,data,bS,s,e){

Use it like so:


If name.php’s output looks like this…


…the above should, upon execution, change the ID “name” to contain the text “Bob.” Should the name variable come up missing, the ajax object will alert you accordingly.


13 Responses to “Parsing JSON with a jQuery ajax object using POST”

  1. 1 Leander

    that was helpful, thank you 🙂

  2. 2 modulatum

    You’re welcome 🙂

  3. 3 Test

    Using Dojo and JSON to Build Ajax Applications

  4. 4 wil

    Can be done with

    var callback = function (data, textStatus) {
    //data now will be a JSON object instead of plain text
    }; url, data, callback, “json”) ;


  5. Nice article.

    You can check a similar simple example for using Jquery/JSON for autopopulate select at

  6. 6 PiterJankovich

    My name is Piter Jankovich. oOnly want to tell, that your blog is really cool
    And want to ask you: is this blog your hobby?
    P.S. Sorry for my bad english

  7. 7 dima

    I use this:

  8. 8 dima

    I use this JSON with a jQuery POST:

  9. I’m new here!
    I like your blogpost. This is very interesting to read.
    I wonder why I didn’t find this blog before.

    I will surely share. Many of my Facebook friends will appreciate it.

    Gracias and keep’em coming!

  10. `., I am really thankful to this topic because it really gives up to date information -*,

  11. Los ejercicios con mancuernas son grandes, muy grandes.

  12. Muy buena pagina. Estoy contento el haberla encontrado.

    Es agradable leer algo intersante.

  13. Hey I know this is off topic but I was wondering if you knew
    of any widgets I could add to my blog that automatically tweet my
    newest twitter updates. I’ve been looking for a plug-in like this for quite some time and was hoping maybe you would have some experience with something like this. Please let me know if you run into anything. I truly enjoy reading your blog and I look forward to your new updates.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: