| | |
Ajax script not working on firefox
Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
•
•
Join Date: Sep 2008
Posts: 33
Reputation:
Solved Threads: 0
Hi all
i have this problem with my ajax script that it is working with IE but not on firefox.this script is updating database. following is AJAX Script::
HTML page is::
PHP Script (ajaxpost.php)::
i get no error on firefox.
i have tried it on firefox 2.0 and 3.0 as well.Please help
Thanks a million in advance
jyoti u
i have this problem with my ajax script that it is working with IE but not on firefox.this script is updating database. following is AJAX Script::
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
<script type="text/javascript"> function ajaxpost(){ var mypostrequest; try { // Firefox, Opera 8.0+, Safari mypostrequest = new XMLHttpRequest(); } catch (e) { // Internet Explorer try { mypostrequest = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { mypostrequest = new ActiveXObject("Microsoft.XMLHTTP"); } } mypostrequest.onreadystatechange=function(){ if (mypostrequest.readyState == 4) { res = mypostrequest.responseText; // These following lines get the response and update the page document.getElementById('result').innerHTML = res; //document.getElementById('result').value = res; } } var parameters = "client="+encodeURI(document.getElementById("client").value)+ "&user="+encodeURI(document.getElementById("user").value)+ "&frmtim="+encodeURI(document.getElementById("frmtim").value)+ "&totim="+encodeURI(document.getElementById("totim").value)+ "&title="+encodeURI(document.getElementById("title").value)+ "&type="+encodeURI(document.getElementById("type").value)+ "&desc="+encodeURI(document.getElementById("desc").value)+ "&date="+encodeURI(document.getElementById("date").value); var url = "https://client.extremescreamproductions.com/leads/ajaxpost.php"; mypostrequest.open("POST", url, true); mypostrequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); mypostrequest.setRequestHeader("Content-length", parameters.length); mypostrequest.setRequestHeader("Connection", "close"); mypostrequest.send(parameters); } </script>
HTML page is::
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
<form method = "post"action="" id="action_time"> <table> <tr><td>Client</td><td><input name="client" type="text" id="client" value="<% print $hname; %>"/> </td> <td>User</td><td><input name="user" type="text" id="user" value="<% print $auth->auth[first_name]." ".$auth->auth[last_name]; %>"/> </td></tr> <tr><td>From</td><td><input name="frmtim" type="text" id="frmtim" maxlength="8" value="<?php echo $cur_time;?>"/></td> <td>To</td><td><input name="totim" type="text" id="totim" maxlength="8"/></td></tr> <tr><td>Title</td><td><input name="title" type="text" id="title"/> </td> <td>Type</td><td><select name="type"><option id="opt1" value="type1">Type 1</option> <option id="opt2" value="type2">Type 2</option> <option id="opt3" value="type3">Type 3</option> <option id="opt4" value="type4">Type 4</option> </select> </td><td></td><td></td></tr> <tr><td>Description</td><td colspan="3"><textarea name="desc" id="desc" rows="5" cols="15">description goes here</textarea> </td></tr> <tr><td>Date</td><td><input name="date" id="date" size="15" value="<?php echo $cur_date;?>"></td> <td colspan="2"> <input type="submit" value="Submit" name ="post_time" id="actiontime" class="buttons" onClick="ajaxpost(); return false;"/></td></tr> </table></form>
PHP Script (ajaxpost.php)::
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
<?php $client = $_POST['client']; $user = $_POST['user']; $frmtim = $_POST['frmtim']; $totim = $_POST['totim']; $title = $_POST['title']; $type = $_POST['type']; $desc = $_POST['desc']; $date = $_POST['date']; $databasehost = "localhost"; $databasename = "db"; $databaseusername ="user"; $databasepassword = "pass"; $con = @mysql_connect($databasehost,$databaseusername,$databasepassword) or die(mysql_error()); @mysql_select_db($databasename) or die(mysql_error()); list($h1,$m1,$s1)=split(":",$frmtim); list($h2,$m2,$s2)=split(":",$totim); if($h1 > $h2){ $second1=$s1+($h1*3600)+($m1*60);//converting it into seconds $second2=$s2+($h2*3600)+($m2*60); }else{ $second2=$s1+($h1*3600)+($m1*60);//converting it into seconds $second1=$s2+($h2*3600)+($m2*60); } if ($second1==$second2) { $total_tim="00:00:00"; } if ($second1<$second2) // { $second1=$second1+(24*60*60);//adding 24 hours to it. } $second3=$second1-$second2; //print $second3; if ($second3==0) { $h3=0; } else { $h3=floor($second3/3600);//find total hours } $remSecond=$second3-($h3*3600);//get remaining seconds if ($remSecond==0) { $m3=0; } else { $m3=floor($remSecond/60);// for finding remaining minutes } $s3=$remSecond-(60*$m3); if($h3==0)//formating result. { $h3="00"; } if($m3==0) { $m3="00"; } if($s3==0) { $s3="00"; } $totaltime = 0; $th = 0; $tm = 0; $ts = 0; $total_tim = "$h3:$m3:$s3"; $pkstr = $frmtim; $pkstr .= $date; $pkstr .= $user; $pk = md5("$pkstr"); $insert_query="insert into actiontime values('$pk','$client','$user','$total_tim','$title','$type','$desc','$date');"; @mysql_query($insert_query,$con); $sel_query = "select total_time from actiontime where client ='$client' AND user = '$user';"; $result = @mysql_query($sel_query,$con); while($values = mysql_fetch_array($result)){ $a = $values['total_time']; list($h,$m,$s)=split(":",$a); $th = $th + $h; $tm = $tm + $m; $ts = $ts + $s; } $second=$ts+($th*3600)+($tm*60); $th=floor($second/3600);//find total hours $remSecond=$second-($th*3600);//get remaining seconds $tm=floor($remSecond/60);// for finding remaining minutes $ts=$remSecond-(60*$tm); $totaltime = "Hr:$th Min:$tm Sec:$ts"; echo $totaltime; ?>
i get no error on firefox.
i have tried it on firefox 2.0 and 3.0 as well.Please help
Thanks a million in advance
jyoti u
Last edited by jyotiu; Sep 13th, 2008 at 3:06 pm.
Hi.
I see two problems.
First, the <select> box is missing the ID attribute.
IE incorrectly uses the name attribute when an ID tag is missing, which explains why this works in IE.
Also, the
(IE and Firefox apparently do stop it tho.)
To fix that, try changing the
I see two problems.
First, the <select> box is missing the ID attribute.
IE incorrectly uses the name attribute when an ID tag is missing, which explains why this works in IE.
Also, the
<input type="submit"> button should not be used to trigger scripts like that. Unlike the onsubmit event of the <form> element, if the <input> onclick event returns false, as it does in your script, the form could still be submitted.(IE and Firefox apparently do stop it tho.)
To fix that, try changing the
<input type="submit"> to <input type="button"> . That should just trigger the script. Last edited by Atli; Sep 14th, 2008 at 4:09 am.
![]() |
Similar Threads
- AJAX generated <select> and FIREFOX (JavaScript / DHTML / AJAX)
- Ajax calls wont work in FireFox! (JavaScript / DHTML / AJAX)
- Debug WebApp in IE7 (JavaScript / DHTML / AJAX)
- AJAX not working on firefox (JavaScript / DHTML / AJAX)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: Currency usage in calculator form
- Next Thread: populating text field in firefox not working
| Thread Tools | Search this Thread |
acid2 ajax ajaxcode ajaxexample ajaxhelp ajaxjspservlets animate automatically beta box browser bug calendar captchaformproblem checkbox child close column createrange() css cursor decimal dependent design disablefirebug dom download dropdown editor element embed engine error events explorer ext file form forms google gwt gxt hiddenvalue highlightedword hint html htmlform ie8 iframe images index internet java javascript javascripthelp2020 jawascriptruntimeerror jquery jsf jsfile jump libcurl listbox math media microsoft mimic mp4 object onmouseoutdivproblem onmouseover onreadystatechange parent paypal pdf php player post problem progressbar regex runtime scroll search security select shopping size software sql text textarea unicode w3c web website window windowofwords windowsxp wysiwyg \n





