[eluser]ssachan[/eluser]
Hello Developers,
I am struggling to get jquery's $post method to get working, here is my code snippet
my jquery code in my view looks like :
$(document).ready(function(){
$(".button").click(function(){
$.post('/welcome/get_messages/', {ajax:'true'},
function(data){
alert(data);
}, 'json');
});
});
the controller welcome.php has the get_messages function that has a simple echo
function get_messages()
{
echo "Hello";
}
however my alert(data) gives me a null.
I am guessing that the URL in post command is incorrect, but then I have tried all the
following as well
'<?=base_url()?>application/controllers/welcome/get_messages'
'<?=base_url()?>/index.php/application/controllers/welcome/get_messages'
but none seem to work.
Please suggest me something that can get my code working.
Thanking in anticipation
Shikhar