在数据库连接codeD HTML返回页面 [英] Encoded HTML in database back to page

查看:111
本文介绍了在数据库连接codeD HTML返回页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在数据库中的以下编码:

I have the following encoding in the database:

<p>
Content <span style="color: #ffffff"><span style="background-color: #ff0000">1+1+1+1=4</span></span>.</p>

我希望把这个值转换成HTML div标签。

I want to put this value into a HTML div tag.

难道我去code以上的值发送回客户方之前,还是我去code将其在客户方?

Do I decode the above value before sending it back to clientside, or do I decode it at clientside?

我使用jQuery和asp.net(VB)

I am using jquery and asp.net (vb)

这是我的jQuery的,这只是显示了JSON数据在屏幕上的HTML,而不是一个警告框弹出。

This is my jquery, which just displays the json data as html on screen, instead of popping up in an alert box.

    function get_page( id ) {
        $.ajax({
            url: 'get_json.aspx?rand=' + Math.random(),
            type: 'POST',
            data: { intPageID:id },
            dataType: 'json',
            success: function(results) { 
                alert(results);
                /*
                $('input#txtID').val(results.id);
                $('input#txtHeading').val(results.heading);
                $('textarea#taContent').val(results.content);
                */
            }
        });

这是一个后续问题:帖子恩code HTML一>

This is a followup question to: Encode HTML before POST

推荐答案

我也不会带code这一切,并发送回一个字符串字面量里(请确保您与\\替换)。它然后可使用注入页:

I wouldn't encode it all, and send it back inside a string literal (make sure you replace " with \"). It can then be injected into the page using:

$('textarea#taContent').html(results.content);

这篇关于在数据库连接codeD HTML返回页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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