Before people jump all over me, I've seen this thread: How do I PHP-unserialize a jQuery-serialized form?
My question is very similar, yet my data is much different. I'm using a AJAX call to do the post, the data posts just fine (jQuery is 1.7). The form & AJAX are dynamically loaded in when a user clicks a few links and drills down to this form & ajax script.
The AJAX looks like: (BTW, I know you're supposed to us .on() but I can't seem to get that to work like I can .live() )
$('#ajaxCaptionForm').live('submit', function(e){
e.preventDefault();
$.ajax({
'type':'POST',
'data':{formData: $('#ajaxCaptionForm').serialize()},
'success':function(){
parent.$.fancybox.close();
}
});
}); // closing form submit
The form looks like:
<form method="Post" action="localhost/controller" id="ajaxCaptionForm" name="ajaxCaptionForm">
<label for="Caption">Caption</label><input type="text" id="Caption" name="Caption" value="Leaf lesions.">
<label for="Keywords">Keywords</label>
<p>Please seperate keywords by a comma
<input type="text" id="Keywords" name="Keywords" value=""></p>
<input type="hidden" id="imageID" name="imageID" value="87595">
<input type="submit" value="Update Image" name="yt3" clicked="true">
</form>
The serialized data looks like: (according to firebug)
formData=Caption%3DFruit%2Blesions.%26Keywords%3D%26imageID%3D87592
When I echo out a response, I get this:
"Caption=Leaf+symptoms+of+++CCDV.&Keywords=&imageID=87655"
My problems are:
- The keywords field is empty, even when I put in content
- The caption field doesn't change on post when I change content.
How do i access each of the variables? Caption, Keywords and Images. $_POST does not work nor:
Yii::app()->request->getParam('imageID')