Running a php script after a query function completes

I’m having trouble figuring out how to run a php script after a jquery script runs. I have a form that is using uploadify to display a status bar and upload an attachment to the server. After that runs I want to run a php script to store all of the other form data. Here is a simplified version with just one post variable (title).


<form action="" method="post" >
		<div id="queue"></div>
		<input type="text"  name="title" placeholder="Video Title..." />
		<input id="file_upload" name="file_upload" type="file">
		<button class="submit" type="button" value="Upload" onclick="javascript:$('#file_upload').uploadifive('upload')">Submit Form</button>
	</form>

	<script type="text/javascript">
		$(function() {
			$('#file_upload').uploadifive({
				'auto'         : false,
				'formData'     : {'test' : 'something'},
				'queueID'      : 'queue',
				'uploadScript' : 'uploadifive.php',
				'onUploadComplete' : function(file, data) {
					console.log(data),
					
					$('form').post('scripts/test_video_demo.php');
					
				}

			});
		});
	</script>

Assuming your onUploadComplete event fires correctly it should be pretty easy to fix this :slight_smile:

I think what you’re trying to do is POST the <form>, however $(“form”) returns a jQuery object of a DOM Node which does not have the .post() method.

If you’d like to post the data from the form you’d have to do it using $.post and manually add the data, e.g.:



$.post("receiver.php", { name: "John", email: "john@example.com" }, function( data ) { /* do something with data */ });

// of course if you just want to send the form data, you could do something like:
$.post("receiver.php", $("#your-form").serialize(), function( data ) { /* do something with data */ });


See http://api.jquery.com/jQuery.post/