求助:.ajax()得到错误的请求400?

我在Wamp上构建了一个Web应用程序(这是我第一次使用服务器),并创建了一个测试数据库,用于查看客户机的数据库。当我们试图实施的时候,我们遇到了很多麻烦。他们使用的是企业服务器(注意:我不知道我在这里说的具体是什么)和MSSQL,在这里我只使用localhost、root,并且在MySQL的Wamp上没有密码——我不知道如何帮助他们实现这个产品,它在我的计算机上工作很好,但是对于他们来说,当我让Ajax打印错误文本时,它显示400。

Ajax 请求:

$.ajax({
        type: "GET",
        url: "getJobList.php",
        data: "hline="+lineLabel[currentLine],
        dataType: "json",
        success: function(data){
              //do successful stuff
        }
}

php文件:

<?php

include "config.php";

$con = mysql_connect($host);
$dbs = mysql_select_db($databaseName, $con);
//get the parameter from URL
$hline=$_GET["hline"];
if (empty($hline)){
    echo "1"; //default rate
}
else{
    $db=mysql_pconnect($host, $user, $pass);//connect to local database
    mysql_select_db($databaseName, $db);//select the database you want to use
    if (!$db){
        echo ("error connecting to database");              
    }
    else{
        //connection successful
        $sql = " SELECT partparameters.cspc,processingrate,setuptime,lotsize,duedate,duetime,homeline
        FROM jobs
        INNER JOIN partcoding 
        ON jobs.partnumber=partcoding.partnumber
        INNER JOIN partparameters
        ON partcoding.cspc=partparameters.cspc
        WHERE homeline = '$hline'
        ORDER BY duedate,duetime ASC";//sql string command
          $result=mysql_query($sql) or die (mysql_error());//execute SQL string command
          //result contains rows
          $arr = array();
          $num = 0;
          while($rows = mysql_fetch_array($result))
          {
            $array[$num] = $rows;
            $num++;
          }
          echo json_encode($array);
    }
}

?>

PHP配置文件:

<?php
$host = "localhost";
$user = "root";
$pass = "";
$databaseName = "gmdata1";
?>

有什么想法吗?提前谢谢你!

更新:修正了我在发帖时误输的错误括号。此外,我是在Chrome上开发的,而用户使用的是Firefox。不过,我认为这应该没什么区别吧,因为他们的渲染方式是一样的。

更新2:

Request URL:

http://usmmcsa0wwt01/ProdSched/getJobList.php?hline=G%20%201

Request Method: GET

Status Code: HTTP/1.0 400 Bad Request

Request Headers 15:24:24.000

X-Requested-With:XMLHttpRequestUser-Agent:Mozilla/5.0 (Windows NT 6.1; rv:20.0) Gecko/20100101 Firefox/20.0Referer:http://usmmcsa0wwt01/ProdSched/index.phpHost:usmmcsa0wwt01Connection:keep-aliveCache-Control:max-age=0Accept-Language:en-US,en;q=0.5Accept-Encoding:gzip, deflateAccept:application/json, text/javascript, */*; q=0.01

Response Headers Δ2ms

Server:CIMPLICITY-HttpSvr/1.0Date:Mon, 22 Apr 2013 19:24:24 GMT

这就是我在Firefox控制台中看到的检查HTTP请求的内容。

Try this -

$.ajax({
        type: "GET",
        url: "getJobList.php",
        data: {"hline": lineLabel[currentLine]},
        dataType: "json",
        success: function(data){
              //do successful stuff
        }
}

Your data is wrong. To pick up $_GET["hline"] you either want hline="+lineLabel[currentLine] in the URL (not recommended) or format the data correctly.

data: {"hline": lineLabel[currentLine]},