我正在尝试使用POST将使用GET的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/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