【发布时间】:2010-09-25 16:50:01
【问题描述】:
我正在使用 php/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();
});
});
短信.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' 设置为 true 时,会显示以下结果 -
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 这是我的基本网址
【问题讨论】:
-
找不到sms.php。所以你的 JavaScript 中的 URL 是错误的,它和你的 HTML 页面在同一个文件夹中吗?