简体   繁体   中英

I don't know why my ajax code returns a 404 error although the url is okay

Ajax returns a 404 error code and it's not a cross-domain problem.

I want to do an ajax request in a TIZEN Web application project, to my WebService which has functions that I need to use in the TIZEN project. Originally, the xhr.status was 0, and it changed to 404 by solving a cross domain problem. The URL parameter is accurate.

What's the problem?

$.ajax({
    crossOrigin:true
    , type: "POST"
    , url: "http://ip/web projeect/web source/function"
    , data: null
    , contentType: "application/json; charset=utf-8"
    , dataType: "json"
    , async: false
    , success: function (jSonResult) {


    },
    error: function (xhr, status, error) {
     console.log(xhr.status);
     console.log(eval("(" + xhr.responseText + ")"));
    }
});

Issue:

app.js (154) :404
app.js (155) :undefined

Yuor url has spaces in it which could be causing problems. Try replacing with hyphens like so:

before: " http://ip/web projeect/web source/function" after: " http://ip/web-projeect/web-source/function "

You mention that the url is on your intranet. Is that url accessible from your application? Try and check it directly from where the application is hosted. Also, check the CORS domains and ensure they are correct.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM