I know some similar questions are also available, but they doesn't help me. I am doing it in Scala Play Framework. I am posting my code below:
var saveNameRequest;
function saveName(){
if(!saveNameRequest){
saveNameRequest=$.ajax({
type:"POST",
url:"edit?editType=saveName",
data: $("#nameForm").serialize(),
complete:function(){saveNameRequest=false},
success: function(data){
alert($("#nameForm").serialize())
}//end success
});
}
}
Form serialization is not working, and an empty string is being printed. nothing is going through post, please help
<form method="POST" name="nameForm" id="nameForm">
<tr>
<td><font color=#3b5999>First Name:</font></td>
<td><input type="text" name="fname" id="fname" value="@fName"></td>
</tr>
<tr>
<td><font color=#3b5999>Middle Name:</font></td>
<td><input type="text" placeholder="optional" name="mname" id="mname" value="@mName" ></td>
</tr>
<tr>
<td><font color=#3b5999>Last Name:</font></td>
<td><input type="text" name="lname" id="lname" value="@lName"></td>
</tr>
<tr>
<td></td>
<td><input name="save" id="save" type="button" value="save" onClick="saveName()"></td>
</tr>
</form>
i found form serialization does not work with facebox in scala 2.10 we have to send data of all fields,it is the only solution that i got,
data:{
"fname":document.getElementById("fname").value,
"mname":document.getElementById("mname").value,
"lname":document.getElementById("lname").value
}