redis php and javascript connection -


i making web chat client use redis pub/sub. having trouble subscribe part. able publish not sure how subscribe. have php script written subscribe (it work when run php) listens , echos message. want able message in javascript. how call php file , listen? tried ajax in jquery , listening echo in success function not seem work. new advice helpful

edit: here javascript

$.ajax({ url:"http://localhost/redisphp.php", type: get, success: function(response){ ...}, ... 

here redis. modeled after link https://xmeng.wordpress.com/2011/11/14/pubsub-in-redis-using-php/

<?php function f($redis, $chan, $msg) { switch($chan) {     case 'chan-1':         echo $msg; } }  ini_set('default_socket_timeout', -1);  $redis = new redis(); $redis->pconnect('128.0.0.0',6378);  $redis->subscribe(array('chan-1'), 'f'); print "\n";  ?> 


Comments