How to Insert into database with Ajax |
[eluser]titolancreo[/eluser]
Hi! I have a calendar and I want to insert some dates by ajax. I don't know what i'm doing wrong but it never goes to my controller... My ajax call in view: Code: var postData = { If I write localhost/PFC/disponibilidad, I go to my controller, so that works, but If I call that function, I always see the error alert. Thanks!
[eluser]TheFuzzy0ne[/eluser]
In the rendered HTML source, what's the value of 'url'? Is it possible that you've haven't prefixed $config['base_url'] with http:// in ./application/config/config.php? Also, if you're using Firefox, the Firebug extension can help a lot. You can monitor network traffic and see where requests are going, and what's being returned.
[eluser]titolancreo[/eluser]
The source code its Ok, I can see h ttp : / / localhost/PFC/disponibilidad And using firebug, I can see it tries to go there, but it returns Internal Server error 500 (The action you have requested is not allowed) OK, I found the problem. I have $config['csrf_protection'] = TRUE; and if I turn it to FALSE, it works... how can I send it by ajax with csrf_protection=TRUE??
[eluser]Otemu[/eluser]
The post here and comments on it should help you solve your issue http://www.web-and-development.com/5-rea...deigniter/
[eluser]titolancreo[/eluser]
[quote author="Otemu" date="1364232954"]The post here and comments on it should help you solve your issue http://www.web-and-development.com/5-rea...deigniter/[/quote] I changed the field because I read that, but it's supposed to be a way to protect the web against csrf, because if not, I can send you an email with a link and when you click it, maybe, I'm changing your profile, or something worse...
[eluser]LuckyFella73[/eluser]
Code: OK, I found the problem. you have to read the value of the hidden csrf field generated automatically and send it along the other post values. For example you have this in your config.php: Code: $config['csrf_token_name'] = 'csrf_field_name'; Code: // javascript part: |
Welcome Guest, Not a member yet? Register Sign In |