我目前正在使用Ajax调用从JavaScript发送数据到PHP脚本的项目。我试图寻找Stackoverflow上的答案,但没有成功,因此我提出了一个问题。Ajax调用似乎在Firefox中失败
此代码在我的Chrome浏览器上正常工作,但在Firefox或Safari中尝试时失败。
$.ajax({
method: "POST",
url: "index.php?option=com_lowbudgetrestvisual&task=sdc.connect&format=json",
cache: false,
data: {
data: data
},
success: function(data, http, state) {},
error: function(http, state, error) {
console.log("Response -> failed");
console.log("http : " + http);
console.log("state: " + state);
console.log("error: " + error);
}
});
编辑:每当我试图google chrome
控制台日志,只是说:Response -> success
。 当我尝试在Firefox中登录时,我收到以下文本。
Response -> failed http = [object Object] state = error error =
编辑2:我想提出一个form
,然后将其提交给PHP script
将其保存在database
使用PHP。另一个ajax
调用的形式是确保电子邮件以表格和管理员身份发送给用户。如何我确信这两个工作是由下面的JavaScript代码:
$('#sdc').on("click", function(e) {
e.preventDefault();
{{ then some codes and the ajax call }}
});
$('#sdc').on("click", function() {
$("#userForm").submit();
});
编辑3:我试过console.log("http : " , http);
,这是我在控制台中看到:
http = Object {
readyState: 0,
getResponseHeader: .ajax/v.getResponseHeader(),
getAllResponseHeaders: .ajax/v.getAllResponseHeaders(),
setRequestHeader: .ajax/v.setRequestHeader(),
overrideMimeType: .ajax/v.overrideMimeType(),
statusCode: .ajax/v.statusCode(),
abort: .ajax/v.abort(),
state: .Deferred/d.state(),
always: .Deferred/d.always(),
then: .Deferred/d.then(),
11 more…
}
有在控制台中的任何错误? –
检查控制台是否存在请求中的错误 –
你有没有检查过你的浏览器控制台,你在mozilla中遇到了什么类型的错误? –