473,395 Members | 1,464 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

My ajax is properly working in chrome and ie but not in firefox 3.6..

11
here are my codes

searchByCategoryForm.php
Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3.     <head>
  4.         <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  5.         <title></title>
  6.         <link rel="stylesheet" type="text/css" href="style2.css" />
  7.         <script type="text/javascript" src="init.js"></script>
  8.         <script type="text/javascript" src="search.js"></script>
  9.     </head>
  10.     <body onload='initRequest()'>
  11.             <div>
  12.                 Search By:<select name="category" id="category" onChange="searchCategory()">
  13.                     <option value="name">Name</option>
  14.                     <option value="serviceID">ServiceID</option>
  15.                 </select>
  16.                 <input name="search" type="text" id='search' size="40" onKeyup="searchCategory()">
  17.                 <div id="searchResult"></div>
  18.             </div>
  19.     </body>
  20. </html>
  21.  
init.js
Expand|Select|Wrap|Line Numbers
  1. var http;
  2. function initRequest()
  3. {
  4.     if (window.XMLHttpRequest) 
  5.     {
  6.         http = new XMLHttpRequest();
  7.     } 
  8.     else if (window.ActiveXObject) 
  9.     {
  10.         http = new ActiveXObject("Microsoft.XMLHTTP");
  11.     }
  12. }
  13.  
search.js
Expand|Select|Wrap|Line Numbers
  1. function searchCategory()
  2. {
  3.     var category=document.getElementById("category").value;
  4.  
  5.  
  6.     if (category=='serviceID')
  7.     {
  8.         if(document.getElementById("search").value.length==2)
  9.         {
  10.             var format=(document.getElementById("search").value)+"-LP-"
  11.             document.getElementById("search").value=format;
  12.         }
  13.     }
  14.     var snput=document.getElementById("search").value;
  15.     var params="category="+category+"&nput="+snput;
  16.     var url="searchByCategory.php";
  17.     searchCat(url,params);
  18. }
  19.  
  20. function searchCat(url,params)
  21. {
  22.     http.open("POST", url, true);
  23.  
  24.     //Send the proper header information along with the request
  25.     http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  26.     http.setRequestHeader("Content-length", params.length);
  27.     http.setRequestHeader("Connection", "close");
  28.  
  29.     http.onreadystatechange = function() 
  30.     {//Call a function when the state changes.
  31.         if(http.readyState == 4 && http.status == 200) 
  32.         {
  33.  
  34.             x=http.responseText;
  35.             document.getElementById("searchResult").innerHTML=x;
  36.  
  37.         }
  38.     }
  39.     http.send(params);
  40. }
  41.  
searchByCategory.php
Expand|Select|Wrap|Line Numbers
  1.  
  2. <?php
  3.     include 'config/opendb.php';
  4.  
  5.     $category = $_POST['category'];
  6.     $nput=$_POST['nput'];
  7.  
  8.     if($category == 'name')
  9.     {
  10.         $searchQuery = "SELECT ServiceID, ClientLastName, ClientFirstName 
  11.                     FROM service a, client b
  12.                     WHERE a.ClientID = b.ClientID 
  13.                     AND CONCAT(ClientLastName,',', ClientFirstName) LIKE '$nput%'";
  14.     }
  15.  
  16.     elseif($category == 'serviceID')
  17.     {
  18.         $searchQuery = "SELECT ServiceID, ClientLastName, ClientFirstName 
  19.                     FROM service a, client b
  20.                     WHERE a.ClientID = b.ClientID 
  21.                     AND ServiceID LIKE '$nput%'";
  22.  
  23.     }
  24.     $res = mysql_query($searchQuery) or die("Error:searchCategory.php--->".mysql_error());
  25.     $ctr=0;
  26.     echo "<table cellspacing='1' style='width:100%;>
  27.     <tr><font color='black'>
  28.     <td bgcolor='#E7ECFD'  width='100' align='center'><strong>ServiceID</strong></td>
  29.     <td bgcolor='#E7ECFD'  width='400' align='center'><strong>LastName</strong></td>
  30.     <td bgcolor='#E7ECFD'  width='400' align='center'><strong>FirstName</strong></td>
  31.     <td bgcolor='#E7ECFD' width='200' align='center'><strong>Service Proposal</strong></td>
  32.     </font></tr>";
  33.     while(list($serviceID, $clientLastName, $clientFirstName)=mysql_fetch_array($res))
  34.     {
  35.         if($ctr%2==0)
  36.         {
  37.             echo "<form action='serviceProposal.php' method=POST><tr><font color='black'>
  38.                     <td bgcolor='#CCCCCC'  width='100' align='center'>$serviceID<input type=hidden name=\"serviceID\" value=\"$serviceID\"></td>
  39.                     <td bgcolor='#CCCCCC'  width='400' align='center'>$clientLastName<input type=hidden name=\"clientLastName\" value=\"$clientLastName\"></td>
  40.                     <td bgcolor='#CCCCCC'  width='400' align='center'>$clientFirstName<input type=hidden name=\"clientFirstName\" value=\"$clientFirstName\"></td>
  41.                     <td bgcolor='#CCCCCC' width='200' align='center'><input type=submit name='serviceProposal' value='Create Service Proposal''></td>
  42.                     </font></tr></form>";    
  43.  
  44.         }
  45.         else
  46.         {
  47.             echo "<form action='bookingOrder.php' method=POST><tr><font color='black'>
  48.                     <td bgcolor='#CEE7FF'  width='100' align='center'>$serviceID<input type=hidden name=\"serviceID\" value=\"$serviceID\"></td>
  49.                     <td bgcolor='#CEE7FF'  width='400' align='center'>$clientLastName<input type=hidden name=\"clientLastName\" value=\"$clientLastName\"></td>
  50.                     <td bgcolor='#CEE7FF'  width='400' align='center'>$clientFirstName<input type=hidden name=\"clientFirstName\" value=\"$clientFirstName\"></td>
  51.                     <td bgcolor='#CEE7FF' width='200' align='center'><input type=submit name='serviceProposal' value='Create Service Proposal' onClick='showserviceproposalform()'></td>
  52.                     </font></tr></form>";
  53.         }
  54.         $ctr++;
  55.     }
  56.     print "</table>";
  57.  
  58.     include 'config/closedb.php';
  59. ?>
  60.  
my database is

Expand|Select|Wrap|Line Numbers
  1. CREATE TABLE `client` (
  2.   `ClientID` int(11) NOT NULL AUTO_INCREMENT,
  3.   `ClientFirstName` varchar(50) NOT NULL,
  4.   `ClientLastName` varchar(50) NOT NULL,
  5.   PRIMARY KEY (`ClientID`)
  6.  
  7.  
  8. CREATE TABLE `service` (
  9.   `ServiceID` varchar(14) NOT NULL,
  10.   `ClientID` int(11) DEFAULT NULL,
  11. )
  12.  
i dont know whats the problem but base on my observation the code didn't go to database..Please help

any suggestions are very appreciated..thanks
Jul 15 '10 #1
9 2376
acoder
16,027 Expert Mod 8TB
Are there any error messages?

Try seeing what you're passing through and the response using Firebug.
Jul 15 '10 #2
ghopz
11
Hi acoder,

Thanks for response, Im using firebug and it returns ok,no error message, and i dont know what is my error,values are passing correctly but my problem is why my codes can't connect to my mysql query. if i run manually my query codes it runs properly so any idea?

Thanks,
ghop'z
Jul 16 '10 #3
acoder
16,027 Expert Mod 8TB
OK, so what's the response from the server?

Have you tried a normal form with post, e.g.
Expand|Select|Wrap|Line Numbers
  1. <form action="searchByCategory.php" method="post">
  2. <select name="category" id="category">
  3. <option value="name">Name</option>
  4. <option value="serviceID">ServiceID</option>
  5. </select>
  6. <input name="nput" type="text" id='search' size="40">
  7. <input type="submit" value="Submit">
  8. </form>
Does that produce the required output?
Jul 16 '10 #4
ghopz
11
@acoder
Hi acoder,

POST http://127.0.01/BOSS/searchByCategory.php 200 OK 24ms

this is the response from the server.

Yap, i try it and it run properly. i dont my error in my ajax..i cant run it properly in in firefox v3.6 but it works as i want it in ie and chrome.

thank,
ghop'z
Jul 17 '10 #5
acoder
16,027 Expert Mod 8TB
OK, but what's the actual response, i.e. the output from the server script?
Jul 18 '10 #6
ghopz
11
@acoder
Hi acoder,

the output shows properly as i wanted it..


thanks,
ghop'z
Jul 19 '10 #7
acoder
16,027 Expert Mod 8TB
That means that part's working and now we're left with the onreadystatechange call back function. On lines 34-5, add breakpoints and watch the variables concerned, i.e. x.

Try alerting the http.responseText, try setting the "searchResult" div to "test", and so on.
Jul 19 '10 #8
ghopz
11
Hi acoder,

Im done on what you said. the values from alert box are correct and but it didn't display on the firefox browser but it is displayed on chrome and ie..


Thanks,
ghop'z
Jul 20 '10 #9
acoder
16,027 Expert Mod 8TB
That's strange. Try something like this:
Expand|Select|Wrap|Line Numbers
  1. document.getElementById("searchResult").innerHTML="Test";
in place of setting it to x. If the responseText is set correctly, I can't imagine why it wouldn't be set correctly unless it's not getting the searchResult div for some reason.
Jul 20 '10 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Danny R | last post by:
I have the following javascript which works in either IE or Firefox but not on both. When I set the code to http_request.open('POST', url, true) - Works in IE only http_request.open('GET',...
3
by: nuchphasu | last post by:
Hi I have a problem on Dropdownlist that connect database and retrieve data by Ajax.I write javascript like this -------------------------------------------------------------------------...
8
by: benoypaul | last post by:
I have the following javascripts which is working in IE, but not working in Firefox and opera. var xmlhttp=null; function showCustomer(str) { xmlhttp=getxmlhttp(); if (xmlhttp==null) {...
33
by: buss123 | last post by:
Hi all, combo box script code was working in IE perfectly with all modes but OnChange event was not working in FireFox(editable mode, if we select valuese that combo box values r...
3
by: rajasree | last post by:
Hi all, am doing a project in PHP. my javascript code is working properly in ie. But its not working in firefox. Please help me my code is as follows; <script language="javascript"...
2
by: agbee1 | last post by:
Hello: I've finally made the effort to ween myself from overly using tables and use CSS for my positioning. However, I am having a problem with my navigational menu properly aligning in Firefox,...
1
by: Mark B | last post by:
This is my first try at using AJAX. I want the calendars to be enabled if the user checks CheckBox1. It works OK for a normal all page refresh but once I introduced the AJAX code it stopped...
5
by: krishna.tunikipati | last post by:
Hi I have updated my firefox browser from 2.0 to 3.0 My AJAX functionality is not working in firefox3.0 But in firefox2.0 it worked fine. and working fine in all IE versions Plz give me a...
2
by: waqasahmed996 | last post by:
hi when i use ajax for sending a request on another server then it is not working in firefox. my code is var url="http://www.example.php" url=url+"?m="+m url=url+"&sid="+Math.random() this...
1
by: waqasahmed996 | last post by:
hi i am trying to send an information to a page which is on another server. var url="http://www.example/.php" this request is working properly on IE but not working on firefox firefox is...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.