没有PHP的jQuery消息系统怎么办?

| 我对此脚本有些兴趣http://www.9lessons.info/2009/06/comment-system-with-jquery-ajax-and-php.html 我看到ajax叫
commentajax.php
。 我想要做的是忽略该php,因为我要发布到json文件,然后从同一文件中获取响应。 我的服务器将使用
POST
PUT
将数据放入数据库,因此不需要使用php,只是语法使我丧命:) 我想使用:
$.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();
}
});
但是then0的样子如何呢? 也许将php替换为:
$.getJSON(\'http://www.xxx.com/json\' , function(data) { ... });
任何想法都可以帮助 谢谢。 编辑1:
i have the server-side script in place
    
已邀请:
如果您已经设置了服务器端脚本,那么又有什么问题呢? 如果您要问如何处理ajax调用,则主要是遍历返回的JSON,然后以某种方式将这些值应用于站点。伪代码:
$.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);
 }
});
    
如果我正确阅读以下内容:
because i want to post to a json file and then get the response from the same file.
您将需要一些服务器端脚本才能将其“发布”到json文件。您如何将数据放入文件中。 您可以从服务器“读取”数据文件,这不是问题,这是将数据放入需要服务器端脚本的文件中的问题。     

要回复问题请先登录注册