"Unexpected end of input"
I'm getting this error when i trigger my $.ajax function to save user details to my database. I already checked a few topic in here but couldn't figure it out.
It has to trigger ajax to php file to save datas to my database. Simple is that. And i know that the syntax error but i already checked it in a few editors.
Couldn't find.
Any suggestions?
Form Code :
<!-- form -->
<form id="uyelikform" name="uyelikform" action="form_kayit.php" method="post">
<!-- <input type="hidden" name="islem" value="form-kayit"> -->
<div id="register-content">
<ul class="form-left">
<li>Ad Soyad</li>
<li>E-Posta</li>
<li>Adres</li>
<li>Telefon</li>
</ul>
<ul class="form-right">
<li><input name="adsoyad" type="text" value="<?php echo strtoupper($user_name); ?>" disabled></li>
<li><input name="eposta" type="text" value="<?php echo $user_email; ?>" disabled></li>
<li><input name="adres" type="text" value="<?php echo $adres; ?>"></li>
<li><input name="telefon" value="<?php echo $tel; ?>" type="text"></li>
</ul>
<div id="form-button">
<a class="form-gonder" href="#">KAYDET</a>
</div>
</div>
</form>
Here is my AJAX Code :
$('.form-gonder').on('click', function(){ // FORM GONDER BUTTON EVENT
$("#uyelikform").submit(); //SUBMIT FORM
});
$("#uyelikform").submit(function(e) {
$('#register-form').fadeOut(1000); // contenti kapat
var postData = $(this).serializeArray();
var formURL = $(this).attr("action");
console.log(postData);
$.ajax(
{
type: "POST",
url : formURL,
data : postData,
dataType: "json",
cache: false,
success:function(data, textStatus, jqXHR)
{
alert("ok");
// $('#register-form').fadeOut(1000); // contenti kapat
},
error: function(jqXHR, textStatus, errorThrown)
{
// alert("Başarılı Olmadı");
console.error("The following error occured: "+ textStatus, errorThrown);
}
});
e.preventDefault(); //STOP default action
});
And here is my PHP
<?php
session_start();
include("../config.php");
$fbId= $_SESSION['Adopen_User'];
// if(isset($_POST['islem']) && $_POST['islem']=="form-kayit") {
// $birth = clear($_POST["objDtarih"]);
$adres = $_POST["adres"];
$tel = $_POST["telefon"];
$kayit = @mysql_query("UPDATE tblusers SET birthday=null,address='$adres',telefon='$tel' WHERE fId=".$fbId."");
// }
?>
EDIT
When I remove JSON in my function it has worked but its not working as i expecting. Because its not updating my records in database.
How can i track AJAX call, i mean i can see that two fields are returning true values in console.log but its not updating at all.
EDIT 2
I added
if(!$kayit) {
echo json_encode(array('returned_val' => '$fbId'));
} else {
echo json_encode(array('returned_val' => 'basarili'));
}
And i saw that there was a sql error. Thats how i figured out.
Thank everyone.