NULL values jQuery Ajax from Seralize

AloneBoss

New Member
I have a issue with Ajax From Submission and NULL values with php/mysql.First I have a simple form.\[code\]<form mehod="post" action=""> Name: <input type=text" name="person[name]" value="" /><br /> Age: <input type="text" name="person[age]" value="" /><br /> Salary: <input type="text" name="person[salary]" value="" /> <a href="http://stackoverflow.com/questions/3629775/process.php" class="add-person">Submit</a></form>\[/code\]Ok now ill post the data to php via ajax pretty simple\[code\]$(".add-person").live('click', function(eve){ eve.preventDefault(); var url = $(this).attr('href'); var data = http://stackoverflow.com/questions/3629775/$(this).closest('form').serialize(); $.ajax({ global: false, type: "POST", url: url, data: data, dataType: 'json', success: function(msg){ alert(msg); } }); })\[/code\]Ok now here comes the problem. For this table the salary field is a float.If I submit the form with a blank value for salary it is not null. So I am getting 0.00 being added to my data.I can easy test for an empty string before adding the data but with lots of fields being like this it becomes bloated. i,e\[code\]if(empty($person['salary']): $person['salary'] = NULL;endif;\[/code\]Any idea why jQuery is making the values no null.Hope you can help.
 
Back
Top