user514310
user514310

Reputation:

Display ajax response into input field

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

Upvotes: 7

Views: 17398

Answers (2)

Pranay Rana
Pranay Rana

Reputation: 176946

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);

Upvotes: 0

simon
simon

Reputation: 1191

Yes.

Using jQuery this looks like:

$.ajax({
  url: '/test.php',
  success: function(data) {
    $('#your-input').val(data);
  }
});

Upvotes: 6

Related Questions