带Post调用的Ajax
我正在尝试使用GET将我的ajax调用转换为使用POST的ajax调用。 这是一个可以很好地与带Post调用的Ajax,ajax,post,get,Ajax,Post,Get,我正在尝试使用GET将我的ajax调用转换为使用POST的ajax调用。 这是一个可以很好地与GET配合使用的工具。 将类型更改为POST无效。数据字符串格式有问题吗 $.ajax({ //type: "GET", //works type: "POST", // Does Not Work url: "/cgi-bin/my_perl.pl", // URL of the Perl script contentType: "application/jso
GET
配合使用的工具。
将类型更改为POST
无效。数据字符串格式有问题吗
$.ajax({
//type: "GET", //works
type: "POST", // Does Not Work
url: "/cgi-bin/my_perl.pl", // URL of the Perl script
contentType: "application/json; charset=utf-8",
dataType: "json",
//data format: "sid=" + sid + "&comments=" + comments,
data: data_string,
error: function(XMLHttpRequest, textStatus, errorThrown) {
alert('AJAX Error');
}, // error
// script call was successful
// data contains the JSON values returned by the Perl script
success: function(data){
if(data.success) {
alert(data.success);
}
else if(data.error!=0) {
alert('We failed');
} //else
} // success
}); // ajax
你说“不行”是什么意思?你的控制台怎么说?我解决了我的问题。我的错误在别处。在我的代码中有一条调试语句,可以在打印后打印JSON而不退出。不知何故,这导致了“AJAX错误”消息。一旦我摆脱了我的调试语句,就可以发布并开始工作了!