AJAX request using jQuery does not work

后端 未结 1 1573
余生分开走
余生分开走 2021-01-28 16:56

So I am new to jQuery and I\'m trying to set up an html page that has tabs. Each tab should show a different html page as follows:

<
相关标签:
1条回答
  • 2021-01-28 17:27

    In your case, it does not work because you're trying to access a file from user computer. It poses security risks because if javascript is able to access local files, javascript is able to steal files from client machine.

    Even when I reference http://www.facebook.com in the url it doesn't work

    The reason for this is: AJAX requests are subject to the same-origin policy. Facebook is on another domain, that's why it does not work.

    One more thing to keep in mind, some browsers think absolute URLs are cross-domain requests even if it's in the same domain, only relative Urls work, so avoid using absolute Urls.

    To fix your issues, try deploying on a server and use relative URLs instead of absolute URLs.

    0 讨论(0)
提交回复
热议问题