简体   繁体   中英

URL in jquery ajax request

When I use ajax call from a modal window, the request url seems not correct. I have a webserver running which can accept http://localhost/search , but not file:///search. How to correct this.

I have a detailed post on what I was trying to do here But the url issue is blocking me currently.

thanks for ur help.

$.ajax({
            type: 'post',
            dataType: 'json',
            url: '/search',
            async: false,
            //data: dataString
            //data: $("#myform").serialize(),
            success: successFn,
            error: errorFn
        });



Request URL:file:///search
Request Headers
Access-Control-Request-Headers:X-Requested-With, Accept
Access-Control-Request-Method:POST
Origin:null
User-Agent:Mozilla/5.0 (X11; U; Linux x86_64; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.204 Safari/534.16

Your url parameter gets the same scheme and hostname as the current page as you don't specify the scheme or hostname in its value, you just supply the path component of the URL. You need to load the page with that .ajax call through HTTP but you're loading it directly from the filesystem.

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