i want to show result data in id myplace
follow value in id="number"
我想在id myplace中显示结果数据跟随id =“number”中的值
if
<input type="text" id="number" name="number" value="5">
i want to show result in id="myplace5"
我想在id =“myplace5”中显示结果
if
<input type="text" id="number" name="number" value="7">
i want to show result in id="myplace7"
我想在id =“myplace7”中显示结果
How can i do that ?
我怎样才能做到这一点 ?
<script>
function Check_register()
{
setTimeout(function(){
$.ajax
(
{
url: 'test.php',
type: 'POST',
data: $('#form_setup').serialize(),
cache: false,
success: function (data) {
$('input').prop('readonly', false); // this line will enable all input after success //
$('#myplace').show();
$('#myplace').html(data);
}
}
)
}, 2000);
}
</script>
2 个解决方案
#1
0
I suppose data
is html containing <input id="number" />
. If so, you can do:
我想数据是包含的html。如果是这样,你可以这样做:
$('#myplace'+ $(data).find("#number").val()).html(data);
#2
0
Since 'Myplace' is an input element, you can't use 'text' or 'html' as you would normally.
由于'Myplace'是输入元素,因此您不能像通常那样使用'text'或'html'。
Instead what you need to do is use jQuerys 'val' function, as follows:
相反,你需要做的是使用jQuerys的'val'函数,如下所示:
$("#myplace").val(html.data);
'html.data' will contain the data that you obtained from your web service, and the call to vall will make sure that it's added to the elements value property.
'html.data'将包含您从Web服务获取的数据,并且对vall的调用将确保将其添加到elements value属性中。
#1
0
I suppose data
is html containing <input id="number" />
. If so, you can do:
我想数据是包含的html。如果是这样,你可以这样做:
$('#myplace'+ $(data).find("#number").val()).html(data);
#2
0
Since 'Myplace' is an input element, you can't use 'text' or 'html' as you would normally.
由于'Myplace'是输入元素,因此您不能像通常那样使用'text'或'html'。
Instead what you need to do is use jQuerys 'val' function, as follows:
相反,你需要做的是使用jQuerys的'val'函数,如下所示:
$("#myplace").val(html.data);
'html.data' will contain the data that you obtained from your web service, and the call to vall will make sure that it's added to the elements value property.
'html.data'将包含您从Web服务获取的数据,并且对vall的调用将确保将其添加到elements value属性中。