jquery消息系统没有php怎么办?
我对此脚本感兴趣 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();
}
});
但是 commentajax.php
会是什么样子呢? 也许将 php 替换为:
$.getJSON('http://www.xxx.com/json' , function(data) { ... });
任何想法都有帮助 谢谢。
edit1:我已经准备好了服务器端脚本
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您已经设置了服务器端脚本,那么问题又是什么?
如果您询问如何处理 ajax 调用,那么主要是循环访问返回的 JSON,并以某种方式将这些值应用到站点。伪代码:
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:
如果我正确地阅读了此内容:
您将需要一些服务器端脚本才能“发布”到 json 文件。您如何将数据放入文件中。
您可以从服务器“读取”数据文件,这不是问题,而是将数据放入您需要服务器端脚本的文件中。
If I am reading this correctly:
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.