$ .post& AJAX不在服务器上工作,但在localhost中工作正常

时间:2015-06-12 04:50:13

标签: javascript php jquery ajax server

我刚刚在服务器上移动了我的网站并被结果,$.post()和AJAX在服务器上工作了。

$.post()始终返回空白数据。在这种情况下,当$.post()显示alert(info) Array()时,您可以在$(document).ready(function () { $("#faq").submit(function () { var data = $(this).serializeArray(); $.post("worker.php", data, function (info) { $(".faq_status").fadeOut(); $(".faq_body").prepend(info); }); return false; }); }); 的一个样本下方办理登机手续:

$.post()

同样的事情发生在所有AJAX&amp; $question = addslashes(htmlentities($_POST['user_question'])); $uip = $_SERVER['REMOTE_ADDR']; if ($question == "") { echo "<p class='alert alert-danger faq_status'>Problem in posting your query. Please resubmit it.</p>"; exit; } $day = date('d'); $month = date('m'); $year = date('Y'); $sql = "SELECT no FROM user_faq WHERE user_ip = '$uip' AND EXTRACT(MONTH FROM asked_time) = $month AND EXTRACT(DAY FROM asked_time) = $day AND EXTRACT(YEAR FROM asked_time) = $year"; $record = $conn->query($sql); if ($record->rowCount() >= 2) { echo "<p class='alert alert-danger faq_status'>Problem in posting your query. please resubmit it.</p>"; } else { $sql = "INSERT INTO `user_faq`(`no`, `question`, `user_ip`,`asked_date`) VALUES (NULL,:que,:ip,Now())"; $query = $conn->prepare($sql); $query->bindValue(":que", $question, PDO::PARAM_STR); $query->bindValue(":ip", $uip, PDO::PARAM_STR); try { $query->execute(); echo "<p class='alert alert-success faq_status'>We have receive your question, answer will be posted here soon!</p>"; } catch (Exception $e) { echo "<p class='alert alert-danger faq_status'>Problem in posting your query. please resubmit it.</p>"; } } 代码。我不知道该怎么做。

这是我的worker.php进度:

use strict;
use warnings;
use 5.010;

my $s = <<END_STRING;
Cat Bag
Dog Hair
Turkey brown Caller
Thirteen,BoyXbox
Mac
LizardDinosaur
JRAinsley-McEwan Class1C
END_STRING

my @s = split/\s*[\n,]\s*|(?<=\S)(?=[A-Z])/, $s;

say join ', ', map qq{"$_"}, @s;

2 个答案:

答案 0 :(得分:0)

您的帖子正在运行,并在提交时返回此回复。

<p class='alert alert-danger faq_status'>Problem in posting your query. please resubmit it.</p>

Firebug extension添加到Firefox以轻松调试您的JavaScript。

答案 1 :(得分:0)

您的localhost上的某些配置或错误报告可能会抑制或忽略服务器上没有的警告。最有效的方法是:

1.检查控制台中与您的代码相关的任何javascript错误。

2.在代码中以可能的行调用某些内容并进行调试以找到脚本中断的位置。

3.如果找到断点,请打开错误报告并检查是否    有任何警告/错误