ajax不会在div上附加数据?

时间:2015-03-19 18:32:15

标签: ajax append

我不知道这里的问题是什么,我尝试追加内容,但不是。

var InPro = false;

$(document).ready(function(){
  var form = $('#form32');
  var submit = $('#submit');
  form.on('submit', function(e) {

                       if(InPro) return;
                       InPro = true;

    // prevent default action
    e.preventDefault();

    // send ajax request
    $.ajax({
      url: 'post.php',
      type: 'POST',
      cache: false,
      data: form.serialize(),
      success: function(data){
InPro = false;
        var item = $(data).hide().fadeIn(800);
        $('#post-show').append(data);
        $("#form32")[0].reset();
      },
    });
  });
});

这里是post.php:

<?php

include_once("config.php");
include_once("verifica.php");

// No direct access to this file
define('IS_AJAX', isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest');
if(!IS_AJAX) {die('Restricted access');}

session_start();

    $user = $_SESSION['user'];
    $comment = $_POST['comment'];

if($comment==""){
die();
}



$ip = getenv("REMOTE_ADDR");
$data = date ("ymdHis");

 $i=mysql_query("INSERT INTO posts (id, foto, user, titulo, youtube, button, data, ip) VALUES ('','0','$user','$comment','$youtube','$button','$data','$ip')");
 $idpostfeed = mysql_insert_id();

 echo"$comment";


?>

和我的表格:

<form id="form32" method="post"> <textarea name="comment" id="comment" class="comment" placeholder=""></textarea> <input type="submit" id="submit" class="button" value="Submit Comment"> </form> <div id=post-show></div>

所以,我想在#post-show div中显示结果,但它不起作用。怎么了?

谢谢!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

0 个答案:

没有答案