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:
$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:
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:
$view["js"] = $this->BrainsHTML->js($js);
PHP Code:
$this->Output->get_views($view, array('login'));
PHP Code:
}
echo view('show', array('show' => $show));
}
public function test()
{
echo csrf_hash();
echo $this->request->isAJAX();
// print_r($this->request->headers());
echo $_POST["test"];
// print_r($_GET);
print_r($this->request->getPost());
// print_r($this->request->getJSON());
// print_r($this->request->getJsonVar());
print_r($this->request->getGet());
print_r($this->request->getMethod());
}
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