exhaler Posted June 30, 2009 Share Posted June 30, 2009 hi, i'm running into some problems trying to make this code submit a form: // fades in the progress bar and starts polling the upload progress after 1.5seconds function beginUpload() { // uses ajax to poll the uploadprogress.php page with the id // deserializes the json string, and computes the percentage (integer) // update the jQuery progress bar // sets a timer for the next poll in 750ms $("#uploadprogressbar").fadeIn(); var i = setInterval(function() { $.getJSON("demo.php?id=" + progress_key, function(data) { if (data == null) { clearInterval(i); location.reload(true); return; } var percentage = Math.floor(100 * parseInt(data.bytes_uploaded) / parseInt(data.bytes_total)); $("#uploadprogressbar").progressBar(percentage); }); }, 1500); } this is a jquery progress bar http://t.wits.sg/jquery-progress-bar/ everything is working just one thing i need to change. I need to submit the form instead of reloading the page after upload the file, since that way i can do some php code. i tried replacing location.reload(true); with this document.getElementById("uploadform").submit(); but nothing happens forum code: <form action="restaccount2.php" method="post" target="progressFrame" id="uploadform" enctype="multipart/form-data" onsubmit="beginUpload();"> <input type="hidden" name="UPLOAD_IDENTIFIER" id="progress_key" value="<?php echo $uuid; ?>" /> <table border="0" width="94%" cellspacing="0" cellpadding="0"> <tr> <td valign="top" align="left" style="height: 1%; width: 51px;"> <font face="Arial, Helvetica, sans-serif" style="font-size: 8pt; font-weight:bold;" color="#6A9192"> Upload </font> </td> <td valign="top" align="left" style="height: 1%; width: 143px;"> <input type="hidden" name="MAX_FILE_SIZE" value="<?php echo $max_file_size ?>"> <input type="file" name="pic" size="8" style="font-family: Arial; font-size: 8pt"><br/> </td> </tr> <tr> <td align="left" valign="bottom" colspan="4"> <input type="image" name="update" src="images/update.gif" width="63px" height="23px"/> <input type="hidden" name="submitimage" value="submitimage" /> <span id="uploadprogressbar" class="progressbar" style="display: inline; font-size: 9pt; font-family:Arial, Helvetica, sans-serif; color:#50BAB8;">0%</span> </td> </tr> </table> also contacted the author but still no reply ideas are welcomed Link to comment https://forums.phpfreaks.com/topic/164302-jquery-progress-bar-submit/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.