Hi,
I am using CakePhp and JQuery in my application of FOrmBuilder. I am having form as like
<form action="/cake_1.2.1.8004/index.php/results/submit1" method="post"
id="ResultSubmit1Form">
<fieldset style="display: none;">
<input type="hidden" value="POST" name="_method"/>
</fieldset>
<div class="input text">
<label for="1">Doj</label>
<input type="text" value="" style="width: 300px;" id="1" name="Doj"/>
</div>
<div class="input text">
<label for="2">Name</label>
<input type="text" value="" style="width: 300px;" id="2" name="Name"/>
</div>
<div class="input textarea">
<label for="3">Address</label>
<textarea style="height: 300px;" id="3" rows="6" cols="30" name="Address"/>
</div>
<div class="input text">
<label for="4">Age</label>
<input type="text" value="" style="width: 200px;" id="4" name="Age"/>
</div>
<br/><br/>
<div class="submit">
<input type="submit" value="submit"/>
</div>
</form>
I want to get all the values entered in the form.
Using JQuery FOrm plugin i have used the following code to retrieve the values like
<script type="text/javascript">
$(document).ready(function(){
$("#submit").eq(0).click(function (){
var serializedFormStr = $("#ResultSubmit1Form :input[value]").serialize();
alert(serializedFormStr);
$.ajax({
type: "POST",
url: "http://localhost/cake_1.2.1.8004/index.php/results/submit1",
data: serializedFormStr,
success: function(msg){
alert( "Data Saved: " + msg);
}//success
});//ajax
});
});//ready
</script>
The alert(serializedFormStr);
shows as
_method=POST&Doj=07%2F09%2F2009&Name=aruna&Address=xyz&Age=22
same i retrieved in my Cakephp controller as
function submit1()
{
echo "In controller ".http_build_query($_POST);//echoes correctly
}
How can i get the individual datas from this query string ..SO that i can save it my database. Please suggest me..