400使用ajax时出现错误的请求错误

400使用ajax时出现错误的请求错误,ajax,web-services,Ajax,Web Services,我正在使用ajax调用Web服务。但是当我在firebug中检查输出时,我得到了400个错误的请求错误。你能告诉我为什么我会出错吗。为什么我会出错。下面的代码有什么问题吗?下面是我写的代码: <script> function HelloWorld() { var sDate = '<cart currency="USD" total="5.38"><cart-shipment total="5.38" shipment-referenc

我正在使用ajax调用Web服务。但是当我在firebug中检查输出时,我得到了400个错误的请求错误。你能告诉我为什么我会出错吗。为什么我会出错。下面的代码有什么问题吗?下面是我写的代码:

<script>

    function HelloWorld() {

        var sDate = '<cart currency="USD" total="5.38"><cart-shipment total="5.38" shipment-reference="33261668"><shipment-tax total="0.39" /><shipment-cost total="0" /><shipment-address><address>33 W 59TH STREET APT 203 </address><zip>60559</zip><city>WESTMONT</city><state>IL</state><country>US</country><phone></phone><name>John Baker</name><attention-of>KID</attention-of></shipment-address><items><item total="4.99"><item-name>Hello Kitty - cupcake</item-name><item-description>Hello Kitty - cupcake</item-description><item-price>4.99</item-price><item-quantity>1</item-quantity></item></items></cart-shipment></cart>';


        var webMethod = "https://abc.com/Services/TransactionService.svc";

        var sr = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/" xmlns:ns2="vp">' +
               '<soapenv:Header/>' +
                    '<soapenv:Body>' +
                        '<tem:ProcessTransaction>' +
                            '<tem:checkOutData>' + sDate + '</tem:checkOutData>' +
                            '<tem:token>5OMc0y1miZN5EFqiZ8IiLn+mzdboyTuTob43Kp4+VcVtrYGQvl7QWJB5OeoPWQpBUej6LSejwE8f16tDhg1EUqDtGGAdn/MM3Gk8MOr0FvFko84ogfhIs9HCUjum2MUN1a/sALjhen+DareUP5wWbIpnu8Eaqg2Tv0RjEsq1bqYblHcXfKIq7anTDzYoHN8Y7LAXgdEhSrVcEIB3+sCCDQ==</tem:token>' +
                            '<tem:transactionDescription>Volusion Order Description</tem:transactionDescription>' +
                        '</tem:ProcessTransaction>' +
                    '</soapenv:Body>' +
                '</soapenv:Envelope>';


        $.ajax({
            type: "POST",
            url: webMethod,
            data: sr,
            contentType: "text/xml",
            dataType: "xml",
            cache: false,
            success: OnSuccess,
            error: OnError
        });
        return false;

    }
    function OnSuccess(data, status) {

        alert(data);

    }

    function OnError(request, status, error) {

        alert(error);
    }


    </script>
    <div>
            <input type="button" value="Soap" onclick="HelloWorld();" />
        </div>

函数HelloWorld(){
var sDate=
用户代理:Mozilla/5.0(Windows NT 6.0)AppleWebKit/537.11(KHTML,如Gecko)Chrome/23.0.1271.95 Safari/537.11
访问控制请求标题:来源、内容类型、接受
接受:/
推荐人:
接受编码:gzip、deflate、sdch
接受语言:en-US,en;q=0.8
接受字符集:ISO-8859-1,utf-8;q=0.7,*;q=0.3

响应标题: 访问控制允许来源:http://yann-asus:81 缓存控制:专用 内容长度:0 日期:2012年12月4日星期二06:42:23 GMT 服务器:Microsoft IIS/7.0 设置Cookie:SessionId=ovpsrxt33jyoi3pzidvxkh0o;路径=/;安全;仅HttpOnly X-AspNet-Version:4.0.30319
X-Powered-By:ASP.NET

我会尝试在contentType中设置utf-8字符集

$.ajax({
        type: "POST",
        url: webMethod,
        data: sr,
        contentType: "text/xml; charset=utf-8",
        dataType: "xml",
        cache: false,
        success: OnSuccess,
        error: OnError
});