too long

i took some interest in this script http://www.9lessons.info/2009/06/comment-system-with-jquery-ajax-and-php.html

and i see that the ajax calls commentajax.php.

what i want to do is to ignore that php, because i want to post to a json file and then get the response from the same file.

my server will use POST or PUT to put the data in the database, so there is no need for me to use php, just the syntax is killing me :)

i want to use :

$.ajax({
type: "POST",
url: "http://www.xxx.com/json",
data: dataString,
cache: false,
success: function(html){
    $("ol#update").append(html);
    $("ol#update li:last").fadeIn("slow");
    document.getElementById('comment').value='';
    $("#name").focus();
    $("#flash").hide();
}
});

but then how would the commentajax.php look like? maybe replace the php with :

$.getJSON('http://www.xxx.com/json' , function(data) { ... });

any idea helps Thanks.

edit1: i have the server-side script in place

If you have the server side scripting set up already, then what is the question again?

If you're asking how to handle the ajax call, then it's mostly a matter of looping through the JSON that you get back, and applying those values to the site in some manner. Pseudo code:

$.getJSON('http://www.xxx.com/json' , function(data) { 
 for(i=0; i<data.comment.length; i++) {
   $(".commentTitle").html(data.comment[i].title);
   $(".commentBody").html(data.comment[i].text);
 }
});

If I am reading this correctly:

because i want to post to a json file and then get the response from the same file.

You are going to need some server side scripting in order to 'post' to the json file. How are you getting the data into the file.

You can 'read' the data file from the server, that's not a problem, it is a matter of getting the data into the file that you need the server side scripting for.