Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 2 of 2 FirstFirst 12
Results 16 to 19 of 19
  1. #16
    New Coder
    Join Date
    Aug 2008
    Location
    India
    Posts
    88
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Strange,if i change the output of php file to static values like this:
    Code:
    ...
    ...
    $result1=mysql_query($query1) or die("Error executing the query");
    while($row=mysql_fetch_row($result1)) {
    array_push($catgrs,$row[0]); }
    echo "<Cats>";
           /*for($i=0;$i<count($catgrs);$i++) {
    echo "<options>".$catgrs[$i]."</options>"; }*/
    echo "<options>check</options>"; 
    echo "<options>check2</options>"; 
    echo "</Cats>";
    require('closeDB.php');
    ?>
    then it works in ajax script.I get alert as 'check' on:
    Code:
    alert (resp.getElementsByTagName("Cats")[0].childNodes[0].firstChild.data);
    Now,i can only conclude that php script is the cause of problem and not getElementsByTagname call...
    Any inputs now...
    Last edited by satish_j; 12-16-2009 at 10:06 AM.
    In love with PHP,Mysql & Javascript

  2. #17
    New Coder
    Join Date
    Aug 2008
    Location
    India
    Posts
    88
    Thanks
    3
    Thanked 0 Times in 0 Posts
    After further troubleshooting,i narrowed it further to the array being called from PHP script:
    I ENTERED 'print_r($catgrs)' in the php script and found that it is returned EMPTY to ajax script,but it is filled properly if i run it directly in browser...
    This is getting weird now..If i run the php script directly in browser,i get the neatly formed xml file with all the values from DB..But,if i alert responseText from ajax script,i get foll
    Code:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <Cats>
    Array
    (
    )
    </Cats>
    In love with PHP,Mysql & Javascript

  3. #18
    New Coder
    Join Date
    Aug 2008
    Location
    India
    Posts
    88
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Prob solved..the issue was in the ajax script.the GET variable send with url was empty...very silly:
    Code:
    var product=document.getElementById('prods').options[prod_idx].value
    changed it to:
    Code:
    var product=document.getElementById('prods').options[prod_idx].text
    Thanks to all for your time..Now,how do i mark this thread as solved..
    Last edited by satish_j; 12-22-2009 at 10:40 AM.
    In love with PHP,Mysql & Javascript

  4. #19
    New to the CF scene
    Join Date
    Jan 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I would also like to ask the question.mark and study.


 
Page 2 of 2 FirstFirst 12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •