Wednesday, 5 October 2011

Ajax script


<script language="javascript" src="geography.js"></script>
<script src="http://localhost/mygeneraldocs/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">

function forcheck() {
              var stateid=document.getElementById('lstState').value;
              var cityid=document.getElementById('lstCity').value;
   
           if(stateid!=''&&cityid!='')
               {
                    $.ajax({
                    url: 'http://localhost/christmate/zipcodetest.php',     //Target path given here        
                    data: "stateid="+stateid+"&cityid="+cityid,                 // passing variables to target path          
                    dataType: 'json',                                                        // type of data u want to get
                    success: function(data)                                               // State
                      {
                     
                     alert(data);
                        document.getElementById('txtZip').value=data;
                   
                        if(data)
                         {
                             alert("success") ;
                             return (true);
                      }
                     else
                      {
                                alert("success") ;
                      }

                  }
                        });
                   
 
        }

 </script>

No comments:

Post a Comment

Visual comparison of the two methods, creating a simple table.

Option 1, using PHP: // PHP $html = '<table>' ;     foreach ( $data as $row ) {     $html .= '<tr>...