CodeIgniter Forums
AJAX, JQUERY and document. ready - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: AJAX, JQUERY and document. ready (/showthread.php?tid=56044)



AJAX, JQUERY and document. ready - El Forum - 11-22-2012

[eluser]neoblasted[/eluser]
Hi,

IM new to ajax in CI and jQuery. Im using a CI HMVC setup.
IM trying to convert a php AJAX IM messenger to CI.


Im loading the chat module in my template in the footer using
Code:
<?php echo modules::run('chat/chat_view');?>

here's the content of the view.
Code:
<div id="main_container">

<a href="[removed]void(0)">Chat with name_lastname</a>


</div> [removed][removed]'
The javascript to cal the chat.js is removed, but it is placed here...

Here a part of the JQUERY Function to call the php AJAX function
Code:
function startChatSession(){  
$.ajax({
url: "http://servername/dir/index.php/en/chat/startchatsession",
dataType: "json",
success: function(data)
{
           do stuff
        }

}


When calling chat.js, the Document.ready in the chat.js is fired, An it call a AJAX function in the chat controller to retrieve sessions and start the timer (To refresh the chat messages). But when it call the AJAX function /chat/startchatsession the Ajax function only return the ECHOS and it just die... Can you give me a clue what im doing wrong ?

Thanks