Problem jQuery in CI 2.0 - 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: Problem jQuery in CI 2.0 (/showthread.php?tid=38613) |
Problem jQuery in CI 2.0 - El Forum - 02-13-2011 [eluser]aataqwa[/eluser] I'm using CI 1.7.2 then the alert on the following script is running normally or perform. and if I use CI 2.0 on the same script then alert ('test') does not appear. Code: [removed] how to solve this problem ? Problem jQuery in CI 2.0 - El Forum - 02-13-2011 [eluser]Eric Barnes[/eluser] You are using POST so check and see if you have CSRF protection turned on. And if you do then you need to add it to the post params: Code: data : "action=do&ci;_csrf_token="+$.cookie("ci_csrf_token"), That is using the jquery cookie library. If that is not the case then use firebug and see what your responses are. Problem jQuery in CI 2.0 - El Forum - 02-13-2011 [eluser]aataqwa[/eluser] thanks for replying my post. if $ config ['csrf_protection'] = FALSE; this problem SOLVED. but if I am use with setting: $ config ['csrf_protection'] = TRUE; $ config ['csrf_token_name'] = 'csrf_test_name'; $ config ['csrf_cookie_name'] = 'csrf_cookie_name'; and if I click echo '<input type="button" value="Resend" id="action"> id="action">' and I do not use form_open then the problem is not resolved. please how to solved this problem? Problem jQuery in CI 2.0 - El Forum - 02-13-2011 [eluser]Eric Barnes[/eluser] CSRF expects you to pass the cookie data on any post. So like I said you will have to manually add the cookie to the ajax call. Problem jQuery in CI 2.0 - El Forum - 02-13-2011 [eluser]aataqwa[/eluser] whether the value of csrf_token_name in the hidden text will keep its value forever ? Code: <div class="hidden"> please enlightenment about the value csrf_token_name ?? Problem jQuery in CI 2.0 - El Forum - 02-13-2011 [eluser]aataqwa[/eluser] this problem solved with using cookies. thank you very muach mr. Eric Barnes. Problem jQuery in CI 2.0 - El Forum - 03-01-2011 [eluser]damien66[/eluser] Hi, I have the same problem but I don't understand how to resolved that. Can you help me ? My javascript is : Code: $.post("create-account", { name: "John", pass: "test" }, and the Php Code: echo 'data received'; The Php is called and executed but, I can not get the response in my javascript Problem jQuery in CI 2.0 - El Forum - 07-18-2011 [eluser]SPeed_FANat1c[/eluser] hello, I am having the problem too: Code: wrap.load(project_url + 'lt/adminuzsakovai/show-company-activity', I am selecting the csrf_token_name from the form which is generated using form_open(). But when I post this value, I cannot access the function, get an error: "NetworkError: 500 Internal Server Error - http://localhost/autoloadsSVN/lt/adminuzsakovai/show-company-activity" when I go to this page using browsers adrres bar then I can acces that url. If I disable csrd protection, then it also works. Why is it not working even when I post the csrf_token_name ? Problem jQuery in CI 2.0 - El Forum - 07-18-2011 [eluser]kaege[/eluser] I don't understand about csrf_token_name because I use CI 2.0 and, as far as I know, CI 2.0 made no such cookie. The cookie was csrf_test_name. Here's an example from my work: jQuery Code: echo "$.post('".site_url()."/siplhp/welcome', 'name=michael&csrf;_test_name=".$this->input->cookie('csrf_test_name')."', function(data) {alert(data)});"; CI Code: if ($this->input->is_ajax_request()) Remember, CodeIgniter (CSRF in this case) always expect $this->input->post('csrf_test_name') in every POST data. |