我一直在学习node.js,后来接触到了express框架。当使用不同的端口时,我似乎无法让它正常工作。
我的ajax是在http://localhost:8888上运行的,这是我在Mac上运行的MAMP服务器。
我的ajax是在http://localhost:8888上运行的,这是我在Mac上运行的MAMP服务器。
$.ajax({
url: "http://localhost:1337/",
type: "GET",
dataType: "json",
data: { },
contentType: "application/json",
cache: false,
timeout: 5000,
success: function(data) {
alert(data);
},
error: function(jqXHR, textStatus, errorThrown) {
alert('error ' + textStatus + " " + errorThrown);
}
});
你可以看到我的Node.js服务器正在运行,地址是http://localhost:1337/。然而,这并没有返回任何内容,反而出现了错误。
有什么解决方法吗?
谢谢,
Ben