在ASP.net中初始闪存后,如何将Ajax数据保留在屏幕上 [英] How do I keep the Ajax data on the screen after a initial flash in ASP.net

查看:49
本文介绍了在ASP.net中初始闪存后,如何将Ajax数据保留在屏幕上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

数据的发布总是闪烁正确的数据,但不会留在div中。我试过把返回假;那没用。我认为它与ASP.net中的runat ='server'有关。



如何在初始正确后将Ajax数据保留在屏幕上flash?



 <   script     type   =  text / javascript    src  < span class =code-keyword> =  http://code.jquery.com/jquery-latest.js >  <   /  脚本 >  
< script type = text / javascript >
$( function (){
$( #<%= Button1.ClientID%>)。bind( click ,fromServer)
});
function fromServer(){
$ .ajax({
type: GET
url: textFromServer.txt
成功:postToPage
});
}
function postToPage(data,status){
$('' #servertext')。text(data);
}
< / 脚本 >
< asp:按钮 ID = Button1 runat = server 文本 = 获取文本 / > < br / >
< div < span class =code-attribute> id = servertext > < / div >

解决方案

< blockquote>( function (){


#<%= Button1.ClientID%>)。bind( click,fromServer)
});
function fromServer(){


.ajax({
type: 获取
url: textFromServer.txt
成功:postToPage
});
}
function postToPage(data,status){


The posting of the data always flashes the correct data but it does not stay in the div. I tried putting "return false;" that did not work. I think it has to do with the "runat='server'" in ASP.net.

How do I keep the Ajax data on the screen after a initial correct flash?

<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript">
    $(function () {
        $("#<%= Button1.ClientID %>").bind("click", fromServer)
    });
    function fromServer() {
        $.ajax({
            type: "GET",
            url: "textFromServer.txt",
            success: postToPage
        });
    }
    function postToPage(data, status){
        $('#servertext').text(data);
    }
</script>
<asp:Button ID="Button1" runat="server" Text="Get Text" /><br />
<div id="servertext"></div>

解决方案

(function () {


("#<%= Button1.ClientID %>").bind("click", fromServer) }); function fromServer() {


.ajax({ type: "GET", url: "textFromServer.txt", success: postToPage }); } function postToPage(data, status){


这篇关于在ASP.net中初始闪存后,如何将Ajax数据保留在屏幕上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆