如何在jquery.post中发送变量
我有一个要发送的对象:如何在jquery.post中发送变量,jquery,post,Jquery,Post,我有一个要发送的对象: var DATE={"nume":nume,"descriere":descriere,"id_sertar":tempId}; 我正在使用这个函数: $.post("http://students.info.uaic.ro/~calin.chifan/api/compartiment/sertar/add.json",JSON.stringify(DATE),function(data){ alert(data); }); 但效果并不好。如何修复
var DATE={"nume":nume,"descriere":descriere,"id_sertar":tempId};
我正在使用这个函数:
$.post("http://students.info.uaic.ro/~calin.chifan/api/compartiment/sertar/add.json",JSON.stringify(DATE),function(data){
alert(data);
});
但效果并不好。如何修复此问题?如果您的页面位于同一台服务器上,则不要对日期进行字符串化
$.post("http://students.info.uaic.ro/~calin.chifan/api/compartiment/sertar/add.json",DATE,function(data){
alert(data);
});
如果您的页面位于不同的服务器上,则使用服务器端脚本(如php Curl)和ajax来获取数据非常简单:
$.post(
"http://students.info.uaic.ro/~calin.chifan/api/compartiment/sertar/add.json",
DATE,function(data){
alert(data);
});
直接发送日期,而无需串接域提供的此脚本
http://students.info.uaic.ro/
(即它是同一个域吗)?如果没有,服务器是否实现CORS?如果没有,您就不能向服务器发出POST请求(从客户端JavaScript)。服务器会说:没有输入变量名,或者类似的内容作为一般说明:请包含确切的错误,而不是“或类似的内容”。您是开发人员,而不是用户。服务器是否需要请求参数或作为请求正文的值