I want to pass the output of my ajax json to my input type textbox. How can i do it. I have this code but my code doesn't work. here it is
我想将我的ajax json的输出传递给我的输入类型文本框。我该怎么做。我有这个代码,但我的代码不起作用。这里是
my script :
我的剧本:
function getUserDetails(id) {
$.ajax({
url : "<?php echo site_url('manager/profile/userDetails/')?>/" + id,
type: "GET",
dataType: "JSON",
success: function(data) {
$('#fname').html(data['user_fname']);
},
error: function (jqXHR, textStatus, errorThrown) {
//alert('Error get data from ajax');
}
});
my html input type tag :
我的html输入类型标签:
<input type="text" class="form-control" id="fname" placeholder="First Name">
1 个解决方案
#1
2
You need to use .val() to add the value into the input. Try the following:
您需要使用.val()将值添加到输入中。请尝试以下方法:
$('#fname').val(data['user_fname']);
also you need to ensure that that the input can handle this value and and is expecting.
您还需要确保输入可以处理此值并且正在期待。
#1
2
You need to use .val() to add the value into the input. Try the following:
您需要使用.val()将值添加到输入中。请尝试以下方法:
$('#fname').val(data['user_fname']);
also you need to ensure that that the input can handle this value and and is expecting.
您还需要确保输入可以处理此值并且正在期待。