来自$ .Ajax调用的返回值未显示在页面源中 [英] Return value from $.Ajax call is not shown in the page source

查看:144
本文介绍了来自$ .Ajax调用的返回值未显示在页面源中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以告诉我为什么$ .Ajax调用的返回值没有显示在页面源中
我是jQuery的新手。我只是从$ .ajax函数返回一个字符串,并将该字符串值显示为标记或

标记的HTML。

Can someone tell me why the return value from $.Ajax call is not shown in the page source I am new to jQuery. I am simply return a string from $.ajax function and displaying that string value as HTML for a tag or

tag.

这是我的jquery代码
................................................. 。

Here is my jquery code ..................................................

$(document).ready(function() {
$.ajax({
    type: "POST",
    url: "AdvService.asmx/GetValuesTesting",
    data: "{}",
    context: document.body,
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    success: OnSuccess,
    error: OnError
});
   function OnSuccess(data, status) {

   alert(data.d);
    $('#dataInTag').html(data.d);
}
function OnError(request, status, error) {
    alert(request.status);
}
    });

* html部分

*html section

<pre>
    <div>
        <p id="dataInTag"></p>
    </div>
    </pre>

* WebMethod **

[WebMethod]
    public string GetValuesTesting()
    {

        string Details = "<b class=\"testClass\">returned data from a WebMethod</b>";
        return Details;
    }

如何将jquery点击事件分配给此返回值(这是ab标签与class =testClass)。

How can I assign a jquery click event to this return value (this is a b tag with class="testClass").

警告提示很好,但返回的值显示在页面上,但没有出现在页面Source中。
请帮助...
并提前致谢...

alert is prompted well but the returned value is shown on page but does not appear in page Source. Please help... and thanks in advance...

推荐答案

你不应该期望查看页面源中显示的AJAX调用的结果。 AJAX是动态的,仅在内存中。

You should not expect to see the results of an AJAX call show up in the page source. AJAX is dynamic and in only in memory.

您可以查看是否使用调试器。例如,如果您使用chrome并查看开发人员工具页面,它将显示包含AJAX调用所做更改的页面源。

You may be able to see if if you use a debugger. For example if you use chrome and look at the developer tools page it will show the page source with changes made by AJAX calls.

这篇关于来自$ .Ajax调用的返回值未显示在页面源中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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