我想在我的节点JS项目中使用AJAX,但运行过程中出现的项目后,我看到了以下错误:如何在节点js中使用ajax?
TypeError: Object function (w) {
if (!w.document) {
throw new Error("jQuery requires a window with a document");
}
return factory(w);
} has no method 'ajax'
我的代码是:
var jq = require('jquery');
jq.ajax({
type: "POST",
url: "http://localhost/sms/index.php",
});
你为什么要这样做? “在我的nodejs项目中使用ajax”?为什么不使用常规的http请求? 'http:// nodejs.org/api/http.html#http_http_request_options_callback'或者其中一个包装库? – deitch 2014-11-23 13:55:46
你使用的是什么版本的jQuery? 1.x不支持非浏览器环境。 – Shaun 2014-11-23 13:57:07
@deitch因为在http模块中,我必须为我的php文件定义httpd conf,但我只是想在本地主机中调用php文件。当使用http模块时出现错误:{[Error:connect ECONNREFUSED] code:'ECONNREFUSED', errno:'ECONNREFUSED', syscall:'connect'} cd。 – h3dgh 2014-11-23 14:30:26