Author Topic: Head scratcher....  (Read 581 times)

0 Members and 1 Guest are viewing this topic.

Offline solonTopic starter

  • Enthusiast
  • Posts: 214
  • Gender: Male
    • View Profile
    • MK Web Design & Development | Cyprus Web Design
Head scratcher....
« on: March 17, 2010, 04:38:52 AM »
Hey guys,
I need some help cause i am really confused here...
I have two AJAX functions (jQuery) the same structure(exact same structure) in two different files.
I am using AJAX with PHP. when i use the one it works in all browsers(IE, Firefox, Chrome).
The second AJAX function works only in Firefox.

This is the first Function with the .php file that calls :

Code: [Select]
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js"></script>
<script type="text/javascript">
function ins(x)
{
  $('#show').load('temp1.php',{
   pr : x
   });
}
</script>
The temp1.php file:
<?php
include ("db.php");


	
	
$pr $_POST["pr"];
	
	
$get_p mysql_query("query") or die (mysql_error());
	
	
$gp mysql_fetch_array($get_p);

	
	
$qry mysql_query("query2") or die(mysql_error());
	
	

	
	
$ch mysql_query("query3") or die (mysql_error());
	
	
$x=0;
	
	
while(
$ch1 mysql_fetch_array($ch))
	
	
{
	
	
	
$pr $ch1[1];
	
	
	
$id $ch1[0];
	
	
	
$x +=1;
	
	
	
echo 
"<table cellspacing='2' width='350'  bgcolor='#333333' border='0' >
	
	
<tr>
         <td  colspan = '2'>
$pr</td>
	
	
 <input type='hidden' id='
$x' value='$id'/>
         <td>"
?> <input type='button' value='X' class='remove' onclick='rem_one(document.getElementById("<?php echo $x?>").value)' /></td></tr>
	
	

	
	
 <?php
	

	
	
}
?>


Now the second function with the .php file that works only in Firefox:
Code: [Select]
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js"></script>
    <script type="text/javascript">
function show_cat(x)
{
  $('#cat').load('get_cat.php',{
   s_id : x
   });
}
</script>
<select name="section">
      <option value="Select">Select Section</option>
      <?php
  
$chs mysql_query("query") or die (mysql_error());
  while($chs1 mysql_fetch_array($chs))
  {
echo '<option  onclick="show_cat('.$chs1[0].')" value="'.$chs1[0].'">'.$chs1[1].'</option>';
  }

  ?>

    </select>
The get_cat.php file:
<option value="Select">Select Cat</option>
<?
php 
	
 include(
"db.php");
	
  if(isset(
$_POST['s_id']))
	
  {
	
	
  
$s_id $_POST['s_id'];
	
	
  
$chc mysql_query("query1") or die (mysql_error());
	
	
  while(
$chc1 mysql_fetch_array($chc))
	
	
  {
	
	
	
	
echo 
'<option onclick="show_br('.$chc1[0].')" value="'.$chc1[0].'">'.$chc1[1].'</option>';
	
	
  }
	
  }
	
  else
	
  {  
	
	
  echo 
'<option value="Select">Error</option>';
	
  }
	
  
	
  
?>


Thanks for any help
Solon
Solon
MK Web Design & Development Ltd
http://www.mkwebcy.com
http://www.backup-easy.com

Offline solonTopic starter

  • Enthusiast
  • Posts: 214
  • Gender: Male
    • View Profile
    • MK Web Design & Development | Cyprus Web Design
Re: Head scratcher....
« Reply #1 on: March 17, 2010, 05:12:42 AM »
Guys i found the solution...
Sorry for taking your time..

The problem was when i was calling the function from
Code: [Select]
<option onclick="function(x)"></option> instead of
Code: [Select]
<select onchange="function(x)"></select>
Solon
MK Web Design & Development Ltd
http://www.mkwebcy.com
http://www.backup-easy.com

Offline isedeasy

  • Enthusiast
  • Posts: 248
    • View Profile
Re: Head scratcher....
« Reply #2 on: March 18, 2010, 10:28:09 PM »
Seeing as you are already using Jquery, why not trigger the events unobtrusively?
I <3 Memcache

Offline solonTopic starter

  • Enthusiast
  • Posts: 214
  • Gender: Male
    • View Profile
    • MK Web Design & Development | Cyprus Web Design
Re: Head scratcher....
« Reply #3 on: March 19, 2010, 01:58:43 AM »
could you explain that a bit more please isedeasy?
Solon
MK Web Design & Development Ltd
http://www.mkwebcy.com
http://www.backup-easy.com