Jquery将结果加载到输入文本中?

时间:2014-11-20 17:56:26

标签: jquery ajax load

您好如何在输入字段中显示加载结果?

<input type="text" placeholder="1" name="bah" style="width:70">

我希望将5替换为输入值

result =    load( "tt.php", { "query":"bt","number":5} );
return $('input[name="bah"]').val(result);

祝你好运

1 个答案:

答案 0 :(得分:0)

http://api.jquery.com/jquery.get/试试这个

$.get( "tt.php",{param: 'test'},function( data ) {
  $('input[name="bah"]').val(data.number);
});

or 

$.ajax({
   type: 'get',
   url: 'tt.php',
   dataType: 'json',
   data: { param: 'test' },
   success: function(data) {
       $('input[name="bah"]').val(data.number);
   }
});