Welcome Guest, Not a member yet? Register   Sign In
Facing problem while using ajax with codeigniter 2.0
#1

[eluser]manishchndk[/eluser]
In config.php i created a variable $config['base_url'] = 'http://localhost/car/';
In Controller folder i created "user" folder and one default controller "welcome.php"
In View folder i created folder "user" folder and view file "welcome_message.php"
when i am running this on browser, default controller loads "new_user.php" from view/user and there i written a code for ajax given below

//loaded all the necessary file required to execute ajax code
[removed]
$(function()
{
$("#check_availability").click(function()
{
var temp = "ABC";
$.ajax
({
type: "POST",
url: '<?php echo base_url(); ?>application/views/welcome_message.php',
data: "login_name="+temp,
sucess: function()
{
alert("hello");
}
});
});
});
[removed]

welcome_message.php
<?php
$name=$_POST['login_name'];
echo $name;
?>

but this code is not working for me, can anybody suggest what to do and where i am making mistake
#2

[eluser]LuckyFella73[/eluser]
Code:
url: ‘<?php echo base_url(); ?>application/views/welcome_message.php’,

You have to send the post data to a controller instead of sending to a view
like you are doing.
#3

[eluser]Rok Biderman[/eluser]
You'll possibly encounter further difficulties with csrf protection. If you do, make form with form_open and then include hidden csrf field into ajax request as well, or try turning off csrf protection off in config for development purposes.




Theme © iAndrew 2016 - Forum software by © MyBB