Jquery ajax函数在IE中工作但在FF中不工作

时间:2010-06-02 07:31:08

标签: jquery ajax

好的,我有这个ajax电话

$('.updatecom .registercomplaint').click(function(){
    updatecomplaints();
});

这将调用函数updatecomplaints()

function updatecomplaints()
{
var tno = $(".updatecom #tno").val();
var status = $(".updatecom #status").val();
if(status=='DONE')
{
    $(".updatecom #con").val('');
}
var tname = $(".updatecom #tname").val();
var rg11 = $(".updatecom #crg11").val();
var rg06 = $(".updatecom #crg06").val();
var tvpins = $(".updatecom #tvpins").val();
var jointer = $(".updatecom #jointer").val();
var cquantity = $(".updatecom #conqty").val();
var nooftv = $(".updatecom #tvno").val();
var misc = $(".updatecom #misc").val();
var tcomments = $(".updatecom #tcomments").val();
var con = $(".updatecom #con").val();
//alert(tno+status+tname+rg11+rg06+tvpins+jointer+cquantity+nooftv+misc+tcomments+con);
$.ajax(
{
    type: "POST",
    url: "up_functions.php",
    data: "ticket="+ tno +"& opt=upcom" +"& status="+ status +"& tname="+ tname +"& rg11="+ rg11 +"& rg06="+ rg06 +"& tvpins="+ tvpins +"& jointer="+ jointer +"& cquantity="+ cquantity +"& nooftv="+ nooftv +"& misc="+ misc +"& tcomments="+ tcomments +"& con="+ con,
    success: function(response)
    {
        alert(response);

    }
});

}

这是我的up_functions.php

$tno = htmlspecialchars(trim($_REQUEST['ticket']));
        $status = htmlspecialchars(trim($_REQUEST['status']));
        $tname = htmlspecialchars(trim($_REQUEST['tname']));
        $rg11 = htmlspecialchars(trim($_REQUEST['rg11']));
        $rg06 = htmlspecialchars(trim($_REQUEST['rg06']));
        $tvpins = htmlspecialchars(trim($_REQUEST['tvpins']));
        $jointer = htmlspecialchars(trim($_REQUEST['jointer']));
        $cquantity = htmlspecialchars(trim($_REQUEST['cquantity']));
        $nooftv = htmlspecialchars(trim($_REQUEST['nooftv']));
        $misc = htmlspecialchars(trim($_REQUEST['misc']));
        $tcomments = htmlspecialchars(trim($_REQUEST['tcomments']));
        $con = htmlspecialchars(trim($_REQUEST['con']));
        $result=$ptr->upcomticketinfo($tno,$status,$tname,$rg11,$rg06,$tvpins,$jointer,$cquantity,$nooftv,$misc,$tcomments,$con);
        echo $result;

这是我的upconticketinfo()php函数

function upcomticketinfo($tno,$status,$tname,$rg11,$rg06,$tvpins,$jointer,$cquantity,$nooftv,$misc,$tcomments,$con)
{
    if($con!='' || $con!=NULL)
    {
        $this->query = "update `booking discription` set `STATUS`='$status',`CLOSED ON`='$con' where `TICKET NO`='$tno'"; 
        $this->q_result = mysql_query($this->query,$this->conn) or die(mysql_error());
        if($this->q_result)
        {
            $query = "update `tech detail` set `TECH NAME`='$tname',`CABLE RG11`='$rg11',`CABLE RG06`='$rg06',`TV PINS USED`='$tvpins',`JOINTER USED`='$jointer',`CONNECTOR QTY`='$cquantity',`NO OF TV`='$nooftv',`MISC`='$misc',`TECH COMMENTS`='$tcomments' where `BOOKING`='$tno'"; 
            $q_result = mysql_query($query,$this->conn) or die(mysql_error());
            if($q_result)
            {
                $response = "updated";
            }
            else
            {
                $response = "error";
            }
        }
        else
        {
            $response = "error";
        }
    }
    else
    {
        $this->query = "update `booking discription` set `STATUS`='$status' where `TICKET NO`='$tno'"; 
        $this->q_result = mysql_query($this->query,$this->conn) or die(mysql_error());
        if($this->q_result)
        {
            $query = "update `tech detail` set `TECH NAME`='$tname',`CABLE RG11`='$rg11',`CABLE RG06`='$rg06',`TV PINS USED`='$tvpins',`JOINTER USED`='$jointer',`CONNECTOR QTY`='$cquantity',`NO OF TV`='$nooftv',`MISC`='$misc',`TECH COMMENTS`='$tcomments' where `BOOKING`='$tno'"; 
            $q_result = mysql_query($query,$this->conn) or die(mysql_error());
            if($q_result)
            {
                $response = "updated";
            }
            else
            {
                $response = "error";
            }
        }
        else
        {
            $response = "error";
        }
    }
    return $response;
}

问题是,这个代码在IE8中运行得很好,即我正在使用......但是它在FF 3.6.3中不起作用... 我检查过每一件事...... 有一点是,只有当我激活firebug调试器时,代码才能在FF上正常工作。否则,ajax成功的警报显示其中没有任何内容...... 帮帮我...

2 个答案:

答案 0 :(得分:2)

如果这不是拼写错误,那就是问题......

data: "ticket="+ tno +"& opt=upcom" +"& status="+ status +"& tname="+ tname +"& rg11="+ rg11 +"& rg06="+ rg06 +"& tvpins="+ tvpins +"& jointer="+ jointer +"& cquantity="+ cquantity +"& nooftv="+ nooftv +"& misc="+ misc +"& tcomments="+ tcomments +"& con="+ con

每个& ....之后你有额外的空间。

如果我是你,我会这样做......

$.ajax(
{
    type: "POST",
    url: "up_functions.php",
    data: {
           "ticket":tno,
           "opt":"upcom",
           "status":status,
           "tname":tname,
           "rg11":rg11,
           "rg06":rg06,
           "tvpins":tvpins,
           "jointer":jointer,
           "cquantity":cquantity,
           "nooftv":nooftv,
           "misc":misc,
           "tcomments":tcomments,
           "con":con 
    },
    success: function(response)
    {
        alert(response);

    }
});

会更容易阅读...

答案 1 :(得分:0)

您对服务器有何期望?

尝试添加

dataType: 'text'
例如,

到您的.ajax()请求。

如果那不是问题,请给Reigel的答案一个机会。我强烈建议使用

$.ajax({
  data: {
       ticket:   tno,
       opt:      upcom,
       status:   status,
       ...
  }
});