I'm having an issue with a JQuery ajax call returning 404, when I can watch the code run on the server - Stack Overflow

admin2025-04-18  2

This is my ajax call:

var myURL = ":1082/WEBSERVICE/getSellSheetData/v0.1";
    muURL = myURL.normalize();

    $.ajax({
        url:myURL,
        data: {
            mode:"M",
            group:"ML",
            itemNumber:itemNumber.normalize(),
        },
        type: "GET",
        dataType:"jsonp",
        async:false,
        jsonp:false,
})

.done(function(ob){
    mgnPct = ob.margin;
    logo = ob.custLogo;
    mainImage = ob.mainImage;
})

.fail(function(xhr,ajaxOptions,thrownError){
    if (xhr.status=="404") {
    console.log(thrownError);
}
});

The console shows only "error".

Any ideas what I'm doing wrong.

When I execute this code, I can watch the API run in debug on my server and populate the output.

So I changed my code to this:

    $.ajax({
    url:myURL,
    data: {
        mode:"M",
        group:"ML",
        itemNumber:itemNumber,
    },
    type: "GET",
    dataType:"jsonp",
    async:true,
    jsonp:false,
    jsonpCallback:"processData",

    error:function(xhr,ajaxOptions,thrownError) {
        if (xhr.status=="404") {
        console.log(thrownError);

        }
    },

    success: processData,


});

function processData(ob) {
    mgnPct = ob.margin;
    logo = "http://example:8080/profoundui/images" + ob.custLogo;
    mainImage = "/" + ob.mainImage;

}

Still getting the error 404. I'm getting very confused. I'm using JSONP to avoid CORS issues.

转载请注明原文地址:http://www.anycun.com/QandA/1744959535a90049.html