Hi everyone,

I'm going to develop this service: I use CakePHP Framework to develop a web 
application (consider this address for it: http://news.webapp.it) that 
allow clients to request news from social networks. I used social API 
(Facebook, twitter, Google+) to send a request to know what client wants. 
It's simple and runs correctly. Each tweet or fb post that I receive can 
have a link and I use it to request a parsing of the webpage linked, making 
an AJAX request for each link to my server that will do CURL connection 
towards the external websites (I use readability lib). 
The problem is in this step: once loaded tweets/posts, I send several ajax 
request to my server, denying any other action that involves communication 
with server (Ajax again, for example - new requests go obviously into a 
queue). 
So, I think that a solution for my problem is to adopt a NodeJS server 
(that I can test at this url http://news.webapp.it/nodejs - because I made 
a folder in CakePHP root, named Nodejs, and customize .htaccess file for 
this) to make those several request for parsing pages, leaving free the 
direct channel with the server for other possible requests from client. But 
I cannot find a solution to do a communication between a CakePHP View 
script (Javascript) and NodeJS server. I tried this

*CakePHP Client-Side : index.ctp*

<input type="button" value="Get AUTH" class="first" />
<p class="codeAuth">CODE for auth: </p>
<p class="result"></p>

<script>
 
$(document).ready(function() {

$('.first').click( function(){ 
    $.getJSON("http://192.aaa.bbb.ccc:8077/&callback=?";,
function(data){
   console.log('Done with success!');
},
function(jqXHR, textStatus, errorThrown) {
     console.log('error ' + textStatus + " " + errorThrown);
});
});
});

</script>


*NodeJS Server-Side: server.js*

var http = require('http');
var querystring = require('querystring');
var url = require('url');
var sys = require('sys');

http.createServer(function (req, res) {
    var pquery = querystring.parse(url.parse(req.url).query);   
    sys.puts("PQUERY: "+pquery);

    var callback = (pquery.callback ? pquery.callback : '');
    sys.puts("Callback: "+ callback);
    var returnObject = {message: "Hello World!"};
    
    var returnObjectString = JSON.stringify(returnObject);

    res.writeHead(200, {'Content-Type': 'text/plain'});
    res.end(callback + '(\'' + returnObjectString + '\')');
}).listen(8077, '192.aaa.bbb.ccc');

sys.puts("Server running at http://192.aaa.bbb.ccc";);

This javascript client side code doesn't work but the server starts 
correctly and if I try http://news.webapp.it/nodejs in the browser address 
field, it return the message "Hello World".
I hope that I have explained my problem. 
Is there anyone that can I help me?

-- 
-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
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 post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

--- 
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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to