|  | 
	                
  
    | 
	 
        เขียน ajax แบบย่อ jquery อย่างไร สามารถเขียนแบบย่อได้หรือต้องเขียนแบบเต็มได้เท่านั้น     |  
    |  |  
 
	
		|  |  |  |  |  
		|  |  | 
          
            | Code (JavaScript) 
 
<script>
function showUser(str) {
  if (str=="") {
    document.getElementById("txtHint").innerHTML="";
    return;
  } 
  if (window.XMLHttpRequest) {
    // code for IE7+, Firefox, Chrome, Opera, Safari
    xmlhttp=new XMLHttpRequest();
  } else { // code for IE6, IE5
    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
  xmlhttp.onreadystatechange=function() {
    if (xmlhttp.readyState==4 && xmlhttp.status==200) {
      document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
    }
  }
  xmlhttp.open("GET","getuser.php?q="+str,true);
  xmlhttp.send();
}
</script>
Code (PHP)
 
 <form>
<select name="users" onchange="showUser(this.value)">
<option value="">Select a person:</option>
<option value="1">Peter Griffin</option>
<option value="2">Lois Griffin</option>
<option value="3">Joseph Swanson</option>
<option value="4">Glenn Quagmire</option>
</select>
</form>
<br>
<div id="txtHint"><b>Person info will be listed here.</b></div>
 
 
 
 Tag : PHP, JavaScript, Ajax, jQuery
 
 
 |  
            | 
 ประวัติการแก้ไข
 2014-10-30 22:39:25
 2014-10-30 22:47:27
 |  
            | 
              
                |  |  |  |  
                |  | 
                    
                      | Date :
                          2014-10-30 22:36:33 | By :
                          kungza007 | View :
                          1029 | Reply :
                          3 |  |  |  
                |  |  |  |  |  
            |  |  
		            |  |  
		|  |  |  |  |  
  
    | 
 
        
          |  |  |  |  |  
          |  |  | 
            
              | Code (JavaScript) 
 
$.get( "test.php", function( data ) {
    alert( "Data Loaded: " + data );
});
 แบบนี้รึเปล่า http://api.jquery.com/jQuery.get/
 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2014-10-31 08:45:13 | By :
                            {Cyberman} |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
        
          |  |  |  |  |  
          |  |  | 
            
              | Code (PHP) 
 funciton showUser(str){
$.get("getuser.php",{q:str},function(data){
alert(data);
});
}
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2014-10-31 08:50:12 | By :
                            ping8252 |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
        
          |  |  |  |  |  
          |  |  | 
            
              | ได้แล้วครับ ขอบคุณมากครับ 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2014-10-31 10:39:45 | By :
                            kungza007 |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  |  |