samedi 4 avril 2015

Beginning jquery on node, how to fix this?

For the following sample:



var $ = require('jquery');
$.ajax({url : 'http://ift.tt/1a1PNfE'})
.then(function(members) {
for (var i in members) {
$.ajax({url : 'http://ift.tt/1gcW4Wp' + members[i].login})
.then(function(member) {
console.log(member.name)
});
}
});


I get this



$.ajax({url : 'http://ift.tt/1a1PNfE'})
^
TypeError: undefined is not a function
at Object.<anonymous> (sample.js:2:3)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.## Heading ##js:310:12)
at Function.Module.runMain (module.js:501:10)
at startup (node.js:129:16)
at node.js:814:3


No idea how to fix. Any help?


Notice that code in this answer is not helping me. I get the same errors or stuff like TypeError: Cannot set property 'cors' of undefined.


1 - I DON'T want advice for why I'm using jquery with node. I have a reason for this, I'm coding in Vim, want to easily test code that will be almost identical to what I'll put in the BROWSER. If you can provide a link for a tutorial for this kind of usage of node, I'd be glad (I've done this before in some remote time, both with node and Rhino).


Aucun commentaire:

Enregistrer un commentaire