hi
public function winPostAction()
{
$this->view->disable();
if($this->request->isPost() == true)
{
if($this->request->isAjax() == true)
{
$email = $this->request->getPost('email', 'email');
$password = $this->request->getPost('password');
$user = new Users();
$user->password = $password;
$user->email = $email;
$user->save();
}
}
else
{
$this->response->setStatusCode(404, "Not Found");
}
}
i want to POST data with ajax , but i can not post data to my database
it is my ajax code
<script type="text/javascript">
$(document).ready(function()
{
$.ajax({
url: "<?php echo $this->url->get('win/win') ?>"
}).done(function(data)
{
console.log(data)
});
$("#form").on("submit", function(e)
{
e.preventDefault();
$.post("<?php echo $this->url->get('win/winPost') ?>", $(this).serialize() , function(data)
{
console.log(data);
}).done(function() {
alert("cool");
}).fail(function() {
alert("error");
})
})
})
</script>
<?php
echo $this->tag->form(
array(
"win/winPost", "method" => "post", "id" => "form"
)
);
?>
<p>
<label for="email">Email:</label>
<?php
echo $this->tag->textField("email");
?>
<label for="password">Password</label>
<?php
echo $this->tag->passwordField("password");
?>
</p>
<p>
<?php echo $this->tag->submitButton("Registrarme"); ?>
</p>
</form>