2014-02-19 28 views
0

如何在HTML中名爲「CurrentVal」的文本字段中回顯'res'值(由php-mysql返回)?ajax在TF中的HTML?

$.ajax({ 
    type:'GET', 
    url:'php/myphp.php', 
    dataType:'json', 
    success: function(response){ 
    var res = response[0].result, 
      stu = response[0].student; 
      //console.log(response); 
} 
}); 
+0

首先,您需要獲得該領域,如果它有一個id,你可以得到元素通過ID,然後將其值設置到資源。 – Musa

+0

謝謝穆薩......這正是我所追求的。你能證明這是一個代碼嗎? – AnnaZeed

回答

1
$.ajax({ 
    type:'GET', 
    url:'php/myphp.php', 
    dataType:'json', 
    success: function(response){ 
    var res = response[0].result, 
      stu = response[0].student; 
$('#CurrentVal').val(res); 
      //console.log(response); 
} 
});