AJAX Post Request does not work |
Hey guys,
I'm new here. I have used CI over the past 10 years and love it. Unfortunately, I'm not getting the hang with everything CI4. So, I have created a form and when I submit it with AJAX (POST), I am getting no result. After further examinations I have come to realize that no data is passed when I execute a Ajax-Request with the type POST. PHP Code: public function index() PHP Code: { PHP Code: $view["head_title"] = 'Login' . TITLE; PHP Code: $view["nav_title"] = TITLE; PHP Code: // $js = 'get("#loginBox", "/login/test2/", "");'; PHP Code: $js = 'var xhr = $.ajax({ PHP Code: url: "/login/test/", PHP Code: type: "POST", PHP Code: dataType: "html", PHP Code: // data: "&test=test", PHP Code: data: { name: "John", location: "Boston" }, PHP Code: success: function(result) { alert(result); }, PHP Code: error: function(result, status, error) { alert("result" + result + ", status" + status + ", error" + error); }, PHP Code: });'; PHP Code: $view["js"] = $this->BrainsHTML->js($js); PHP Code: $this->Output->get_views($view, array('login')); PHP Code: } The alert shows the following: 4c352b93ef0c5b27c340fe27f2db69c11Array ( ) Array ( ) get I have been on this for hours now and I am out of ideas. Please help me and let me know if you need more infos about the setup. From where I stand it should be pretty simple, as I have never had an issue with this code in CI3. Thanks, Alain
I finally found the solution.
The Rewrite directives in .htaccess were not set properly. Sorry about that.
I always like to get my forms working first then switch them over to Ajax.
What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
|
Welcome Guest, Not a member yet? Register Sign In |