Display ajax response into input field

后端 未结 2 654
北海茫月
北海茫月 2021-01-18 09:28

is there any way to display ajax response into input field? thanks

相关标签:
2条回答
  • 2021-01-18 10:15

    Yes.

    Using jQuery this looks like:

    $.ajax({
      url: '/test.php',
      success: function(data) {
        $('#your-input').val(data);
      }
    });
    
    0 讨论(0)
  • 2021-01-18 10:22

    check this : jQuery.ajax()

    $("id").val(
     $.ajax({
          url: "script.php",
          global: false,
          type: "POST",
          data: ({id : this.getAttribute('id')}),
          dataType: "html",
          async:false,
          success: function(msg){
             alert(msg);
          }
       }
    ).responseText);
    
    0 讨论(0)
提交回复
热议问题