Arc Forumnew | comments | leaders | submitlogin
Alpha release of a JSON parser / generator (github.com)
8 points by CatDancer 5942 days ago | 3 comments


1 point by thaddeus 5938 days ago | link

Ok I just looked up details about JSON over the past 10 min. This may seem like a noob question, but hey I'm a noob :).

What's the value in JSON or even XML when I can use a standard http Get/Post Ajax call than runs an arc function outputting my data in html format to any htmldiv I want?

Thanks, T.

-----

1 point by CatDancer 5938 days ago | link

If you want to make an AJAX call from your browser to fetch some HTML from your server and put that data inside a div, you don't need to use JSON for that. Just have your Arc op return the HTML.

Untested, so I apologize for any mistakes:

  (defop grabdata req
    (pr "This is my <i>HTML</i> content!"))
and, in the browser, using for example JQuery (http://jquery.com/) as a convenient way to make the AJAX call:

  $.get("http://yourserver.com/grabdata", function (data) {
    $('#your_div').html(data);
  });
replaces the contents of the div that has the id "your_div" with the HTML content returned by grabdata.

-----

1 point by thaddeus 5938 days ago | link

I don't think I learned anything about JSON, but holy crow jquery is awesome.... The chaining methods alone just made my day! :)

-----