Ajax request not working in ExpressJS

60 views
Skip to first unread message

pradeep raj

unread,
Oct 27, 2014, 5:52:09 AM10/27/14
to nod...@googlegroups.com

Hi Sir/Madam,


If i make an ajax request from the client side to the server side 'http://192.168.0.83:3131/getWorkspace' i got request fails error means(the request was cancelled).

Client Code : apf.ajax("http://192.168.0.83:3131/webcompile?callback=?",{ method:"GET", crossDomain: true, contentType: "text/plain; charset=utf-8",
callback:function(data){ if (data != "undefined" || data != null || data !="") { console.log("o/p: "+data); alert("O/P :"+ data.toString()); } } });


Server Code : app.get("/getWorkspace", function( req, res) { //getting session values var _workspacename = req.session.worksapcename2; console.log(_workspacename); res.send(_workspacename); });

when normally i'm redirect this url in browser it's works fine. but when i make ajax call it's return Undefined

Kindly please help me on this,

Thanks in advance,

Pradeep Raj.K

Adrian Lynch

unread,
Oct 27, 2014, 10:45:35 AM10/27/14
to nod...@googlegroups.com
Check your server logs to see if the request is coming in.

Remove all logic in your client-side callback and do a basic request.

What library are you using on the client?

What error are you getting in the console on the client?

Adrian

--
Job board: http://jobs.nodejs.org/
New group rules: https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
---
You received this message because you are subscribed to the Google Groups "nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+un...@googlegroups.com.
To post to this group, send email to nod...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nodejs/0c4d1aa6-311b-4251-b316-6dac057ec7ca%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages