SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot
    Join Date
    Dec 2011
    Posts
    122
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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).

    Code:
    <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>

  2. #2
    Under Construction silver trophybronze trophy AussieJohn's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    776
    Mentioned
    11 Post(s)
    Tagged
    0 Thread(s)
    Assuming your onUploadComplete event fires correctly it should be pretty easy to fix this

    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.:

    Code javascript:
     
    $.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/
    var details = {
    . . web: "afterlight.com.au",
    . . photos: "jvdl.id.au",
    . . psa: "usethelatestversion.com"
    }


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •