user-authentication.js - $.ajax is undefined

28 views
Skip to first unread message

Nitin Gautam

unread,
Feb 5, 2017, 11:46:01 PM2/5/17
to Node-RED
I am trying to call using ajax login API but it is erroring as undefined for $

I believe $ defintion is missing and I need Jquery to install but in many of areas in code it is working without that how that working?

Nick O'Leary

unread,
Feb 6, 2017, 4:19:36 AM2/6/17
to Node-RED Mailing List
Hi,

As you've mentioned user-authentication.js, I assume you are creating a custom authentication module as described here: http://nodered.org/docs/security#custom-user-authentication

That module runs in the node.js runtime, not in the browser. If you really want to use jQuery in there, you can npm install it: https://www.npmjs.com/package/jQuery and require it into your module - see the examples from the jQuery module page.


Nick

On 6 February 2017 at 04:46, Nitin Gautam <gautam...@gmail.com> wrote:
I am trying to call using ajax login API but it is erroring as undefined for $

I believe $ defintion is missing and I need Jquery to install but in many of areas in code it is working without that how that working?

--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+unsubscribe@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.
To view this discussion on the web, visit https://groups.google.com/d/msgid/node-red/1ff58bb1-2394-4f44-b41d-27651a2f9a69%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Nitin Gautam

unread,
Feb 6, 2017, 9:04:33 AM2/6/17
to Node-RED
I Nick thanks for reply I have installed jQuery and jquery both + jsdom. But getting error for

TypeError: require(...).jsdom(...).createWindow is not a function


so trying now what I am missing seems jsdom is not being identified properly, so let me search what is wrong.



On Monday, February 6, 2017 at 3:19:36 AM UTC-6, Nick O'Leary wrote:
Hi,

As you've mentioned user-authentication.js, I assume you are creating a custom authentication module as described here: http://nodered.org/docs/security#custom-user-authentication

That module runs in the node.js runtime, not in the browser. If you really want to use jQuery in there, you can npm install it: https://www.npmjs.com/package/jQuery and require it into your module - see the examples from the jQuery module page.


Nick
On 6 February 2017 at 04:46, Nitin Gautam <gautam...@gmail.com> wrote:
I am trying to call using ajax login API but it is erroring as undefined for $

I believe $ defintion is missing and I need Jquery to install but in many of areas in code it is working without that how that working?

--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+u...@googlegroups.com.

Nitin Gautam

unread,
Feb 6, 2017, 9:41:20 AM2/6/17
to Node-RED
fixed by using below


require("jsdom").env("", function(err, window) {
   
if (err) {
        console
.error(err);
       
return;
   
}
   
     $
= require("jquery")(window);
});

Reply all
Reply to author
Forward
0 new messages