0

I have country and states select box which loads based on the selection of country. This code is working fine offline but when i put it to server it says (Problem while using XMPHTTP: Not Found).

<script language="javascript" type="text/javascript">
    function getXMLHTTP() { //function to return the xml http object
    var xmlhttp=false;  
    try{
        xmlhttp=new XMLHttpRequest();
    }
    catch(e)    {       
        try{            
            xmlhttp= new ActiveXObject("Microsoft.XMLHTTP");
        }
        catch(e){
            try{
            xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
            }
            catch(e1){
                xmlhttp=false;
            }
        }
    }

    return xmlhttp;
    }
    function getState(cate_id) {        
    var strURL="findsect.php?country="+cate_id;
    var req = getXMLHTTP();
    if (req) {
        req.onreadystatechange = function() {
            if (req.readyState == 4) {
                // only if "OK"
                if (req.status == 200) {                        
                    document.getElementById('statediv').innerHTML=req.responseText;

                } else {
                    alert("Problem while using XMLHTTP:\n" + req.statusText);
                }
            }               
        }           
        req.open("GET", strURL, true);
        req.send(null);
    }       
    }
    </script>

This code is in findsect.php

  <html>
    <head>
    <title></title>
    <style type="text/css">
    .input-short { 
        width: 25% 
        }
    </style>
    </head>

    <?php 
    $country=$_GET['country'];
    $con = mysql_connect('localhost','root',''); 
    if (!$con) {
        die('Could not connect: ' . mysql_error());
    }
    mysql_select_db('my');
    $query="SELECT * FROM gallery_section WHERE related='$country'";
    $result=mysql_query($query);

    ?>
    <select class="input-short" name="Section" onchange="getCity(<?php echo $country?>,this.value)">
    <option>Select Section</option>
    <?php while ($row=mysql_fetch_array($result)) { ?>
    <option value="<?php echo $row['title']?>"><?php echo $row['title']?></option>
    <?php } ?>
    </select>
    </html>
BenMorel
  • 34,448
  • 50
  • 182
  • 322
  • check with var strURL="findsect.php?country="+cate_id; may be findsect.php is not found – user3470953 May 05 '14 at 09:57
  • not the file is there. Another solution? – user3314254 May 05 '14 at 09:59
  • **Danger**: You are using [an **obsolete** database API](http://stackoverflow.com/q/12859942/19068) and should use a [modern replacement](http://php.net/manual/en/mysqlinfo.api.choosing.php). You are also **vulnerable to [SQL injection attacks](http://bobby-tables.com/)** that a modern API would make it easier to [defend](http://stackoverflow.com/questions/60174/best-way-to-prevent-sql-injection-in-php) yourself from. – Quentin May 05 '14 at 10:00
  • @user3314254 — The server says the file is not there. I'd tend to believe it. Use the developer tools in your browser to figure out what URL is actually being requested and compare it to your server's error logs – Quentin May 05 '14 at 10:00

0 Answers0