我使用php/ajax提交表单而不刷新页面。这里是我的文件 -jquery ajax请求萤火虫错误
coupon.js
jQuery(document).ready(function(){
jQuery(".appnitro").submit(function(e) {
$.ajax({
url : "http://174.132.194.155/~kunal17/devbuzzr/wp-content/themes/street/sms.php",
type : "post",
dataType: "json",
data : $(this).serialize(),
success : function(data) {
for(var id in data) {
jQuery('#' + id).html(data[id]);
}
}
});
//return false or
e.preventDefault();
});
});
sms.php
<?php
//process form
$res = "Message successfully delivered";
$arr = array('mess' => $res);
echo json_encode($arr);//end sms processing
unset ($_POST);
?>
这里是代码为我的html页面 -
<form id="smsform" class="appnitro" action="http://174.132.194.155/~kunal17/devbuzzr/wp-content/themes/street/sms.php" method="post">
...
</form>
<div id="mess" style="background:green;"></div>
现在,当我点击提交按钮没有任何反应,萤火虫显示下面的控制台面板 -
POST http://174.132.194.155/~kunal17/devbuzzr/wp-content/themes/street/sms.php
404 Not Found 1.29s `jquery.min.js (line 130)`
Response
Firebug needs to POST to the server to get this information for url:
http://174.132.194.155/~kunal17/devbuzzr/wp-content/themes/street/sms.php
This second POST can interfere with some sites. If you want to send the POST again, open a new tab in Firefox, use URL 'about:config', set boolean value 'extensions.firebug.allowDoublePost' to true
This value is reset every time you restart Firefox This problem will disappear when https://bugzilla.mozilla.org/show_bug.cgi?id=430155 is shipped
当我设置“extensions.firebug.allowDoublePost”来然后按照真实的结果显示 -
POST http://174.132.194.155/~kunal17/devbuzzr/wp-content/themes/street/sms.php
404 Not Found 1.29s `jquery.min.js (line 130)`
Response -
{"mess":"Message successfully delivered"}
谁能帮助我在固定的404没有发现这一错误的萤火。为什么它会显示jquery.min.js (line 130)
?
P.S - 不要担心http://174.132.194.155/~kunal17/devbuzzr/wp-content/themes/street这是我的基本URL
它无法找到sms.php。所以你的JavaScript中的URL是错误的,它是否与HTML页面上的表单位于同一个文件夹中? – 2010-09-23 06:56:38