Jquery $ .post返回null值

时间:2015-07-11 11:35:11

标签: php jquery

以下代码在我的localhost上完美运行,但在托管网站后。它没有返回准确的值。如果我使用警报返回邮政编码的默认值。返回一个值。例如:

$.post('sendingOffer.php',{id:id},function(data){
    if(data=="true"){
        CurrentBtn.html('<b>Offer Send</b>').css('background','#dce6f1');
        CurrentBtn.html('<b>Offer Send</b>').css('outline','1px solid #dce6f1');
        CurrentBtn.html('<b>Offer Send</b>').css('border','1px solid white');
        CurrentBtn.html('<b>Offer Send</b>').css('mouse','cursor');
        CurrentBtn.attr("disabled","disabled");
        CurrentBtn.removeAttr("href");

    }else if(data=="false"){
        alert('You have reached the maximum number of 5 offers you can send today');
        }else if(data=="not null"){
            alert("offer already sent");
        }else if(data=="assigned"){
            alert('This job is already assigned to another person');
        }else{
      alert(data);// a value is returned
}
    });

这是JQuery代码:

$('.buyerRequest').click(function(){

    var CurrentBtn=$(this);
    var id=$(this).attr('id').replace('id_','');


$.post('sendingOffer.php',{id:id},function(data){
    if(data=="true"){
        CurrentBtn.html('<b>Offer Send</b>').css('background','#dce6f1');
        CurrentBtn.html('<b>Offer Send</b>').css('outline','1px solid #dce6f1');
        CurrentBtn.html('<b>Offer Send</b>').css('border','1px solid white');
        CurrentBtn.html('<b>Offer Send</b>').css('mouse','cursor');
        CurrentBtn.attr("disabled","disabled");
        CurrentBtn.removeAttr("href");

    }else if(data=="false"){
        alert('You have reached the maximum number of 5 offers you can send today');
        }else if(data=="not null"){
            alert("offer already sent");
        }else if(data=="assigned"){
            alert('This job is already assigned to another person');
        }
    });

});

这是php代码

<?php
require'set_session.php';
    require'../../../php/connection.php';
    $buyer_id='';
    $order_id='';
    $buyer_name='';
    $user_name=getUserField('user_name');

if(isset($_POST['id'])){
     $order_id=$_POST['id'];

    $query="select `account_id` from `place_order` where `order_id`='$order_id'";
    $query_run=mysql_query($query);

    while($row=mysql_fetch_array($query_run)){
         $buyer_id=$row['account_id'];
        }
}


        $query="select `inbox_id` from `inbox` where `seller_name`='$user_name' and `date` ='".date("Y-m-d")."'";
        $query_run=mysql_query($query);
        $query_num=mysql_num_rows($query_run);
        $queryExst="select `inbox_id` from `inbox` where `seller_name`='$user_name' and `order_id`='$order_id'";
        $query_runE=mysql_query($queryExst);
        $query_numE=mysql_num_rows($query_runE);
        $queryId="select `inbox_id` from `inbox` where `order_id`='$order_id' and `buyer_name` != ''";
        $query_runId=mysql_query($queryId);
        $query_numId=mysql_num_rows($query_runId);

        if($query_num < 5){
        if($query_numE==0){
            if($query_numId == 0){
            $query="insert into `inbox` values('','$buyer_id','$order_id','".date("Y-m-d")."','$user_name','','unread','unread','')";
            $query_run=mysql_query($query);
            echo'true';
        }else{
            echo'assigned';
        }

        }else{
            echo'not null';
        }
        }else{
            echo'false';
        }

?>

0 个答案:

没有答案