我不确定这个请求有什么问题,但这是正在发生的事情..
浏览器似乎认为我正在发出跨域请求,但是我正在向请求来自的同一页面发出请求。
我调用了一个名为 search 的函数,并在我的 google chrome 开发控制台中返回了这个函数
编辑:
当我加载 jquery-1.0.2.min.js 时发生同样的事情
服务器返回: {"readyState":4,"status":404,"statusText":"error"}
Bad request search.js?1383509337:48
POST http://example.com/transaction/search jquery-2.0.3.js:7845
x.support.cors.e.crossDomain.send jquery-2.0.3.js:7845
x.extend.ajax jquery-2.0.3.js:7301
search search.js?1383509337:22
(anonymous function) search.js?1383422028:17
x.event.dispatch jquery-2.0.3.js:4676
y.handle jquery-2.0.3.js:4360
函数搜索()
function search(user, transactionDate, vendorField, amountField, accountField, departmentField, subDepartmentField, statusField, projectidField){
var url = "/transaction/search";
var ajax = jQuery.ajax({
type: 'POST',
dataType: 'json',
url: url,
data: {
user: user,
transactionDate: transactionDate,
vendorField: vendorField,
amountField: amountField,
accountField: accountField,
departmentField: departmentField,
subDepartmentField: subDepartmentField,
statusField: statusField,
projectidField: projectidField
},
beforeSend: function(data){
$('#searchSpinner').show();
console.log("Sending request");
},
success: function(data){
console.log("Successful request");
data = JSON.parse(data, true);
loadTransactions(data['response']['transactions']);
$('#searchSpinner').hide();
},
error: function(data){
console.log("Bad request");
$('body').html(JSON.stringify(data));
$('#searchSpinner').hide();
}
}).done(function(data){
console.log("finished");
$('#searchSpinner').hide();
});
}