11156180
头几天开始关注node,想用express和ajax弄个网页做练习,但是请求时一直readystate:0.........statusText:error,请各位前辈指点下 后台代码 var express = require('express'); var app = express(); app.get('/', function(req, res){ console.log(req); //res.send('hello world'); res.send({name:1234}); }); app.listen(3000); console.log("server has started");
前台代码 $.ajax({ type:"get", contentType: "application/json", dataType: "json", url:"http://localhost:3000/", async:true, data:{id:12345}, success:function(data) { alert(data); // alert($.parseJSON(data)); // $("#indexhtml").test(JSON.stringify(data)); }, error:function(err) { alert(JSON.stringify(err)); } }); 多谢