Progress Bar with PHP, Ajax (Jquery), and MySQL

Ok, I have been working at this for some time now and seem to be stop dead in my tracks on this. Im sending a string of values through ajax post to a server side script that sends mail out and reports the percent done. What I need to do is grab the percent done for the server sides script and feed that into a progress bar (which is made and styled)… The problem is not the server side script but the front end page, this crashes.

this is the javascript inside main.php

<?php
	require_once('settings.php');
	isloggedin();
	
	if (isset($_POST["FILE"])) {
		$filename = "mailer/" . $_POST["FILE"];
	} else {
		$filename = "undefined";
	}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
    <title>Register Account User</title>
    <link rel="stylesheet" type="text/css" href="_scripts/CSS/style-cms.css"/>
    <script type="text/javascript" src="_scripts/JS/jQuery-Minified.js"></script>
    <script type="text/javascript" src="_scripts/JS/jquery.tools.min.js"></script>
    <script type="text/javascript" src="_scripts/JS/jquery.progressbar.min.js"></script>
    <script type="text/javascript" src="_scripts/JS/tiny_mce/jquery.tinymce.js"></script>
	<script type="text/javascript" src="_scripts/JS/functions.js"></script>
    <script>
		// initialize the jquery code
		$(document).ready(function() {
			// setup up the progress bar inside of a overlay
			$("#pb1").progressBar();
			// setup for show and hide of menu bars
			var filename = "<?=$filename?>";
			if (filename == 'undefined') {
				$('#mailerinfo').hide();
				$('#mailer').hide();
			} else {
				$('#template').hide();
			}
			// setup of tinymce for text and html editing inside of a template or a blank template
			$('textarea.tinymce').tinymce({
				script_url : '/_scripts/JS/tiny_mce/tiny_mce.js',
				theme : "advanced",
				plugins : "pagebreak,advimage,advlink,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,paste,directionality,nonbreaking,template,advlist",
				theme_advanced_buttons1 : "bold,italic,|,justifyleft,justifycenter,justifyright,justifyfull",
				theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,undo,redo,|,link,unlink,anchor,image,help,code,|,insertdate,inserttime,preview",
				theme_advanced_toolbar_location : "top",
				theme_advanced_toolbar_align : "left",
				theme_advanced_statusbar_location : "bottom",
				theme_advanced_resizing : false
			});
			// The triger event for sending the mail, no need for some outside function to start use it. Click and go!
			$('#triger').overlay({mask: {color: '#4c4c4c',loadSpeed: 200,opacity: 0.9},closeOnClick: false, effect: 'apple'}).click(function() {
				// hide the done so that it can send it all
				//$('.done').hide();
				var filen = $('#file').val();
				var subjt = $('#subject').val();
				var fromn = $('#fromname').val();
				var fromm = $('#fromemail').val();
				// testing string www.wraithwarez.net/scripttesting.php?ACCESS=mailer&SUBJECT=testingsubject&FROMEMAIL=testmail&FROMNAME=testing person&FILE=template.html
				var dataString = 'ACCESS=mailer&SUBJECT=' + subjt +'&FROMEMAIL=' + fromm + '&FROMNAME=' + fromn + '&FILE=' + filen;
				$.ajax({
					type: 'post',
					url: 'core-functions.php',
					async: true,
					data: dataString,
					success: function(msg) {
						while (msg <= 100) {
							$("#pb1").progressBar(msg);
							if (msg == 100) {
								$('.done').show();
							}
						}
					}
				});
			});
		});
	</script>
</head>

<body onload="DetectBrowser()">

<div class="content">
    <div class="hd">
    	<div class="verison">Verison .01 Beta</div>
    </div>
    <div class="mn">
<?php include_once("_scripts/menu.php") ?>
	</div>
    <div class="bd">
        <div class="bodyleft">
<?php include_once("_scripts/user.php") ?>
		<div class="top"></div>
            <div class="mid">
            	<b>Mass Mailer Options</b>
                <hr />
                <a href="manage-mailer.php">Mass Mailer</a><br />
                <hr />
				<a href="">Add Contacts</a><br />
                <a href="">List Contacts</a>
            </div>
            <div class="bot"></div>
		</div>
        <div class="bodyright" id="template">
        	<div class="key"><b>Template Selection</b></div>
        	<div class="log-top"></div>
            <div class="log-mid">
            	<form action="<?=$_SERVER['PHP_SELF']?>" method="post" name="template">
            	<table width="100%" border="0" cellspacing="2" cellpadding="0">
                    <tr>
                        <td width="20%">Choice Your Template</td>
                        <td width="75%">
                        	<select name="FILE" class="input" style="width: 150px;">
<?php
$dir = "mailer/";
echo ("<option value='notemplate'>No Template</option>");
if (is_dir($dir)) {
    if ($dh = opendir($dir)) {
        while (($file = readdir($dh)) !== false) {
			if($file == "." || $file == "..")
			continue;
            echo ("<option value='" . $file . "'>" . $file . "</option>");
        }
        closedir($dh);
    }
}
?>
                            </select>
                        </td>
                        <td width="5%"><input type="image" name="postART" value="POST" class="submit-btn" src="img/buttons/webdesign-wraithwarez-cms2_48.png" alt="submit" title="submit" /></td>
                    </tr>
                </table>
                </form>
            </div>
            <div class="log-bot"></div>
        </div>
        <div class="bodyright" id="mailerinfo">
        	<div class="log-top"></div>
            <div class="log-mid">This is just a sample of the text that we are show for samples and shit! This will contain information about the mailers, contacts and status of the information inside of the database and everything else...</div>
            <div class="log-bot"></div>
        </div>
        <div class="clear"></div>
        <div class="bodycenter" id="mailer">
        	<form name="email">
            <div class="span-top"></div>
            <div class="span-mid">
            	<b>Mass Mailer</b>
                <div class="right" id="triger" rel="#status" style="width: 80px; height: 15px; padding-right: 5px; background-image: url(../../img/buttons/webdesign-wraithwarez-cms2_54.png);"></div>
            </div>
            <div class="span-bot"></div>
            <div class="span-top"></div>
            <div class="span-mid">
            	<input name="file" type="hidden" value="<?=$filename ?>" id="file" />
                <table width="100%" border="0" cellspacing="2" cellpadding="0">
                    <tr>
                        <td width="10%"><b>Subject: </b></td>
                        <td width="40%"><input name="subject" type="text" class="input" id="subject" size="60" /></td>
                        <td width="10%"><b>From Name: </b></td>
                        <td width="40%"><input name="fromname" type="text" class="input" id="fromname" size="60" /></td>
                    </tr>
                    <tr>
                    	<td></td>
                        <td></td>
                        <td><b>From Email: </b></td>
                        <td><input name="fromemail" type="text" class="input" id="fromemail" size="60" /></td>
                    </tr>
                </table>
                <br />
                <b>Email Content: </b>
                <textarea id="elm1" name="content" rows="40" cols="" style="width: 100%" class="tinymce">
<?php 
	if (isset($_POST["FILE"])) {
		if ($_POST["FILE"] != "notemplate") {
			echo(file_get_contents($filename));	
		}
	}
?>
				</textarea>
            </div>
            <div class="span-bot"></div>
            </form>
        </div>
        <div class="clear"></div>
    </div>
    <div class="mnft">
        <hr>
<?php include_once("_scripts/bottommenu.php") ?>
    </div>
    <div class="ft">
<?php include_once("_scripts/copy-mod.php") ?>
    </div> 
</div>
<div class="overlay" id="status">
    <div class="progress">
        <span class="progressBar" id="pb1">0%</span>
	</div>
    <div class="done">
    </div>
</div>
</body>

</html>

This is the sever side script that I run
[php]
if ($_POST[‘ACCESS’] == ‘mailer’) {
if ($_POST[‘SUBJECT’] != ‘’ && $_POST[‘FROMEMAIL’] != ‘’ && $_POST[‘FROMNAME’] != ‘’ && $_POST[‘FILE’] != ‘’ ) {

		// there is code here that is not important to the script with the progress bar...
		
		foreach ($result as $row):
			echo(percent($total, $num));
			$total++;
		endforeach;
	} else {
		return('ERROR: 201 - There was no action specified!');
	}
}

[/php]

If anyone can help, I would really appreciate it.

Sponsor our Newsletter | Privacy Policy | Terms of Service