使用asp.net中的ajax方法更新div [英] update div using ajax method in asp.net

查看:77
本文介绍了使用asp.net中的ajax方法更新div的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在div中显示innerhtml....在onclick事件中,将值传递给服务器端方法,替换了现有的div内容..但div没有更新原因?

i am displaying innerhtml in the div....in onclick event am passing the values to the server side method there am replaceing the existing div content..but div is not updating why?

推荐答案

此示例将a=1发送到/Service1.asmx/testJSON,然后获取data.d
并通过
This sample send a=1 to /Service1.asmx/testJSON then get data.d
and show it in divResults by


(''#divResults'').html(data.d);
将其显示在divResults中
(''#divResults'').html(data.d);

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"></script>
    <script type="text/javascript">
        function getProducts(a) {
            try {


.ajax({ 类型:" , contentType:" , 网址:" , 数据:" , dataType:" , 成功:功能(数据){ alert(" );
.ajax({ type: "POST", contentType: "application/json; charset=utf-8", url: "/Service1.asmx/testJSON", data: "{'a' : '1'}", dataType: "json", success: function (data) { alert("Succeed");


这篇关于使用asp.net中的ajax方法更新div的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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