简体   繁体   English

jQuery AJAX在发出请求之前失败

[英]JQuery AJAX fails before making the request

This is what I'm doing: 这就是我在做什么:

$.ajax({
    "url":"localhost:8888/check_app",
    "success":function(data) {
        alert("success!");
        callback(data);
    },
    "error":function(data){
        alert(JSON.stringify(data));
    }
});

Which errors out on both FF and Chrome. FF和Chrome都出现哪些错误。 Firebug shows that no XHR request was made. Firebug显示没有XHR请求。


Edit: I use node.js on the backend; 编辑:我在后端上使用node.js; and the console shows it did not receive any requests. 并且控制台显示它没有收到任何请求。

When I change $.ajax to $.get, I do see a XHR request in Firebug, but the url is some weird encoded string I do not recognize. 当我将$ .ajax更改为$ .get时,我确实在Firebug中看到了XHR请求,但是url是一些我无法识别的奇怪编码字符串。

I've been working on this whole afternoon... 我整个下午都在工作...

Right now, your browser is looking for a folder named localhost:8888 and a file in that folder called check_app . 现在,您的浏览器正在寻找一个名为localhost:8888的文件夹,并在该文件夹中寻找一个名为check_app文件。

What you want is to make the path absolute, with http://localhost:8888/check_app instead. 您想要的是使路径为绝对路径,而改为使用http://localhost:8888/check_app

First, the object keys don't have quotes around them - it should be url : not "url" : 首先,对象键周围没有引号-它应该是url:而不是“ url”:

You may also need to place an http:// in front of the URL for $.ajax where as it may not be required for $.get...strange behavior, but possible I suppose. 您可能还需要在$ .ajax的URL前面放置一个http://,因为$ .get ... strange行为可能不需要它,但我想这可能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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