Jquery Ajax没有打到Webservice

时间:2012-11-11 09:05:26

标签: jquery ajax web-services

我正在使用位于应用程序根文件夹中的本地Web服务。 我尝试使用Jquery Ajax方法命中服务方法,然后返回404错误。但是相同的代码在我的本地机器上工作正常。在实时服务器上测试时会发生此问题。我是否需要在web.config文件中进行一些设置..请指导我这个

以下是网络服务的链接: - http://solentcarleasing.co.uk/solentwebservice.asmx

  • 我正在使用MVC3

先谢谢

这是代码: -

function BindPrices(){

    var derivative = $("#hdncderid").val();
    var Terms = "24";
    var Milage = "10000 mpa"

    Milage = $("#AnnualMilageList :selected").text();
    Terms = $("#drpterm :selected").val();

    var IsSpecial = 1
    var Type = "C"
    var IsMaintances = "0"

    var CtrServicePath = "http://solentcarleasing.co.uk/solentwebservice.asmx/GetLeasingPriceForTechinalPageByDerID";

    $.ajax({
        type: "POST",
        url: CtrServicePath,
        data: "{derivativeids:" + derivative + ", term: '" + Terms + "', milage: '" + Milage + "', IsSpecial: " + IsSpecial + ", typ: '" + Type + "', maintain: '" + IsMaintances + "'}",
        async: false,
        contentType: "application/json; Characterset=utf-8",
        dataType: "json",
        success: function (data1) {

            var p = eval("(" + data1.d + ")");

            if (p.length > 0) {

                $.each(p, function (i, k) {

                    if (parseFloat(k.BusinessPrice1).toFixed(2) != 0.00 || k.BusinessPrice1 != 0.0) {

                        document.getElementById("SpnBussinessPrice").innerHTML = "£ " + parseFloat(k.BusinessPrice1).toFixed(2);
                        document.getElementById("SpnPersonalPrice").innerHTML = "£ " + parseFloat(k.PersonPrice1).toFixed(2);
                        document.getElementById("SpnPersonlInialsPrice").innerHTML = " £ " + parseFloat(k.IntialsPersonalPayment1).toFixed(2);
                        document.getElementById("SpnBussinessInialsPrice").innerHTML = " £ " + parseFloat(k.IntialsBusinessPayment1).toFixed(2);

                        document.getElementById("spnquotepayment").innerHTML = "£ " + parseFloat(k.BusinessPrice1).toFixed(2);
                        document.getElementById("spnquoteinitialpayment").innerHTML = " £ " + parseFloat(k.IntialsBusinessPayment1).toFixed(2);
                        document.getElementById("spnquoteterm").innerHTML = Terms + " months";
                        document.getElementById("spnquotemilage").innerHTML = Milage.replace("mpa", "") + " miles";

                        document.getElementById("spnpermonthP").innerHTML = " per month";
                        document.getElementById("spnpermonthB").innerHTML = " per month";
                    }
                    else {


                        document.getElementById("SpnBussinessPrice").innerHTML = "Price on Request";
                        document.getElementById("SpnPersonalPrice").innerHTML = "Price on Request";
                        document.getElementById("spnpermonthP").innerHTML = "";
                        document.getElementById("spnpermonthB").innerHTML = "";

                        document.getElementById("SpnPersonlInialsPrice").innerHTML = " £ " + parseFloat(k.IntialsPersonalPayment1).toFixed(2);
                        document.getElementById("SpnBussinessInialsPrice").innerHTML = " £ " + parseFloat(k.IntialsBusinessPayment1).toFixed(2);

                        document.getElementById("spnquotepayment").innerHTML = "Price on Request";
                        document.getElementById("spnquoteinitialpayment").innerHTML = " £ " + parseFloat(k.IntialsBusinessPayment1).toFixed(2);
                        document.getElementById("spnquoteterm").innerHTML = Terms + " months";
                        document.getElementById("spnquotemilage").innerHTML = Milage.replace("mpa", "") + " miles";


                    }
                }
               );
            }
        },
        error: function (res) {
        }
    });
}

1 个答案:

答案 0 :(得分:0)

Hey pardeep dhingra我认为您在 结束时';'

var derivative = $("#hdncderid").val();
var Terms = "24";
var Milage = "10000 mpa" // <------------------------------here

Milage = $("#AnnualMilageList :selected").text();
Terms = $("#drpterm :selected").val();

var IsSpecial = 1    // <----------------------------------here
var Type = "C"  // <---------------------------------------here
var IsMaintances = "0" // <--------------------------------here

Plz将 ; 放在那里,看看你是否有效。

由于