我想在隐藏值和div中显示ajax的成功结果。但它显示在一个或其他
<input type="hidden" runat="server" ID="piechartval" value="HERE" />
<div class="rankadvancement "><img src="Assets/Images/imgLoading.gif" style="width: 16px;" />HERE<div>
here is my javacript:
success: function(data) {
//var $response = $(data);
//oGlobal = $response.find('#pie').text()
//alert(oGlobal);
var selector ="";
var control = '<%=piechartval.ClientID%>';
var str = data;
var n =str.lastIndexOf('</span>');
n = n.replace("</span>","");
var a = str.substring(n + 1,str.length - 6);
alert(a);
document.getElementById(control).value = a; ----- this value in hidden
$(selector).html('').html(a);
$('.rankadvancement').html(data); --- this one in div
}
谢谢!
我修改了我的结果,现在我希望看到隐藏值的整个结果。 但它仅在输出中显示此部分,但隐藏变量具有完整值(
<div class='col-sm-4'>
<div class='pie-chart1 pie-chart pie-number easyPieChart' data-percent=33% style='width: 220px; height: 220px; line-height: 220px;'>33% <canvas width='220' height ='220'/></div>
)
但是当我在aspx页面中复制结果和硬编码时,它可以正常工作,但不能通过ajax。
这是我获得成功的目标:
<div class='col-sm-4'>
<div class='pie-chart1 pie-chart pie-number easyPieChart' data-percent=33% style='width: 220px; height: 220px; line-height: 220px;'>33% <canvas width='220' height ='220'/></div>
</div>
<div class='rankadvancement'>
<div class='row-fluid'>
<span class='span2'>
<div class='percent'>33%</div>
</span>
<span class='span10'>
<a href='javascript:loadRankAdvancement(6);' class='next'><img src='Assets/Images/btnArrowRight.png' /></a>
<a href='javascript:loadRankAdvancement(4);' class='previous'><img src='Assets/Images/btnArrowLeft.png' /></a>
<h3>Pearl Ambassador</h3>
<div class='progress progress-magenta'>
<div class='bar' style='width: 33%'></div>
</div>
</span>
</div>
<div class='goals'>
<div class='clearfix'></div>
</div>
</div>
尝试但不工作:我可以看到隐藏的varibale中的值,但实际上无法在网页上看到结果:
<!///<input name="ctl00$Content$piechartval" type="hien" id="Content_piechartval" class="piechartval" value=" <div class='col-sm-4'><div class='pie-chart1 pie-chart pie-number easyPieChart' data-percent=33% style='width: 220px; height: 220px; line-height: 220px;'>33% <canvas width='220' height ='220'/></div></div><div class='rankadvancement' <img src='Assets/Images/imgLoading.gif' style='width: 16px;'><div class='row-fluid'><span class='span2'><div class='percent'>33%</div></span><span class='span10'><a href='javascript:loadRankAdvancement(6);' class='next'><img src='Assets/Images/btnArrowRight.png' /></a><a href='javascript:loadRankAdvancement(4);' class='previous'><img src='Assets/Images/btnArrowLeft.png' /></a><h3>Pearl Ambassador</h3><div class='progress progress-magenta'><div class='bar' style='width: 33%'></div></div></span></div><div class='goals'><div class='clearfix'></div></div></div>"
答案 0 :(得分:0)
我建议您不要在服务器响应中使用标记,但坚持使用JSON。我的猜测是,您正在使用错误标记来阻止input
或div
标记。如果你返回JSON那么它就像。
success: function (data) {
$('#piechartval').val(data.val);
$('.rankadvancement').text(data.val);
}
答案 1 :(得分:0)
根据我自己的理解,您只需要更新输入值属性
<input type="hidden" runat="server" ID="piechartval" value="HERE" />
success: function(data) {
$('input#piechartval').attr(value,data); --- this one in hidden input
$('.rankadvancement').html(data); --- this one in div
}
答案 2 :(得分:-1)
试试这段代码,看看会发生什么:
<input type="hidden" runat="server" class="piechartval" ID="piechartval" value="HERE" />
<div class="rankadvancement "><img src="Assets/Images/imgLoading.gif" style="width: 16px;" />HERE<div>
success: function(data) {
$('.piechartval').val(data); --- this one in hidden input
$('.rankadvancement').html(data); --- this one in div
}
编辑:在旁注上,使用隐藏div上的类,因为ID会因runat="server"
而改变。修复了代码以反映出来。