首页 \ 问答 \ 使用javascript从编码的json数据显示实际的html或链接(Displaying actual html or link from encoded json data using javascript)

使用javascript从编码的json数据显示实际的html或链接(Displaying actual html or link from encoded json data using javascript)

我从ajax调用返回以下内容

{"dataList":[{"date":"August 27, 2013","text":"<a href=\"http:\/\/www.example.com\/test.aif\" 
title=\"Click here to listen\" target=\"\">Click here to listen<\/a> to the test from
2013!"},],"record_count":3}

我通过循环将数据添加到屏幕上......

$.each(data.dataList, function(index, element) {
    $('#news_data').append($('<h1>', {
        text: element.date
    }));

    $('#news_data').append($('<h2>', {
       text: element.text                
    }));
});

结果是页面显示所有html而不是实际的URL。 所以我的问题是:如何让它实际显示链接而不是HTML? 我应该以不同的格式返回数据吗?


I have the following being returned from an ajax call

{"dataList":[{"date":"August 27, 2013","text":"<a href=\"http:\/\/www.example.com\/test.aif\" 
title=\"Click here to listen\" target=\"\">Click here to listen<\/a> to the test from
2013!"},],"record_count":3}

I'm adding the data to the screen by looping through it...

$.each(data.dataList, function(index, element) {
    $('#news_data').append($('<h1>', {
        text: element.date
    }));

    $('#news_data').append($('<h2>', {
       text: element.text                
    }));
});

The result is the page displaying all the html and not the actual URL. So my question is: How do I get it to actually display the link and not the HTML? Should I be returning the data in a different format?


原文:https://stackoverflow.com/questions/19945218
更新时间:2024-05-03 11:05

相关问答

更多
  • 分段错误的原因是您必须访问主机上的data_str内存才能分配data_str(n1)%b。 由于data_str在设备内存中,而不在主机内存中,因此会出现分段错误。 从理论上讲,编译器可以创建一个主机temp,分配它,然后将它复制到data_str(n1)%b的描述符,但这不是今天的CUDA Fortran的一部分。 您可以通过自己创建temp来解决此问题: subroutine allocate_mem(n1) implicit none integer, inten ...
  • 您提供的示例不是可分配的数组,而是一个简单的静态数组,它只存在于创建它的范围内。 一旦变量超出范围,通常会释放分配给静态数组的内存,但这取决于其他情况,例如,如果它是隐式保存的,等等。 要成为可分配的数组,它的声明必须具有ALLOCATABLE。 此外,您需要分配它。 可分配数组的重点是FORTRAN将为您管理释放。 一旦阵列超出范围,fortran将为您解除分配。 这样,此阵列不存在内存泄漏风险。 示例改编自http://www.fortran90.org/src/best-practices.html ...
  • 你可以简单地在你的类型中插入一个指针。 这看起来像: type a type(a), dimension(:), pointer :: array end type 然后您可以简单地按照需要的大小分配数组。 You can simply insert a pointer in your type. This would look like: type a type(a), dimension(:), pointer :: array end type You can then simply al ...
  • 对于标准检查,您可以使用-std标志 -std = std指定程序符合的标准,可以是f95', f2003', f2008', gnu'或`legacy'之一。 要“强制” gfortran编译代码,您必须使用它识别的语法 For standard checking you can use -std flag -std=std Specify the standard to which the program is expected to conform, which may be one of f95', ...
  • 编译器的ABI可以不同。 您不应该直接传递结构,而是在子例程中构建它们并使用指针,您应该将其作为type(c_ptr)或假定的大小数组传递(但是可以发生复制!)。 与Fortran 2003中的C的互操作性并不仅仅意味着与C交互,而是与C可互操作的任何其他编译器。它可以是不同的Fortran编译器。 请注意,除非类型为sequence或bind(C) ,否则在更多位置声明相同类型并将其用作相同类型是违反Fortran规则的。 这是您的程序不符合标准的另一个原因。 called.f90: subroutine ...
  • 使用数组描述符 (也称为dope向量)处理可分配数组,指针数组以及假设的形状数组参数。 任何编译器都可以拥有自己的数组描述符结构。 它可以在编译器手册中找到。 但是描述符有一种标准化格式,用于与C(以及可能与C通信的Fortran之外的其他软件)进行通信。 编译器内部可能不会使用此标准描述符,但它可以是。 如果它也在内部使用,那么编译器在调用C可互操作过程时不必准备新的描述符。 例如,gfortran计划支持标准描述符“最好是原生格式” 。 英特尔在https://software.intel.com/en ...
  • 我认为使用intent(out)会导致派生数据类型中的可分配数组被释放。 使用intent(inout)使用gfortran 4.7修复了我的问题。 I think using intent(out) causes the allocatable array in the derived datatype to be deallocated. Using intent(inout) fixed the problem for me using gfortran 4.7.
  • 使用无限多态实体是非常苛刻的。 为容器类型添加已定义的输入/输出过程并不能解决您的问题,因为问题不在于容器本身。 相反,它是容器的组件 ,它是多态的并且需要定义的I / O过程。 不幸的是,因为该组件是无限多态的,所以不可能定义这样的过程。 1 此外,实际上不会使用您定义的容器类型的I / O过程。 您只为未格式化的输入和输出定义了过程,但write(*,*)是(列表定向的)格式化输出。 至于如何解决这个问题:在某些时候你必须决定你的无限多态实体是什么。 使用无限多态实体的部分原因是棘手的,因为内部和派生类 ...
  • 在select类型(或关联)构造中,无论select是否具有该属性,关联名称都不会具有allocatable属性(16.5.1.6p2)。 在您的情况下,选择器也缺少该属性 - value伪参数未声明为可分配。 不允许将未分配的实际参数与非可选的不可分配的伪参数相关联。 除此之外,您不允许在选择类型或关联构造中使用未分配的选择器。 您需要在调用之前将value实际参数分配给某个长度, value关联名称将在select类型构造内具有该固定长度。 或者,将可分配字符变量包装为派生类型中的组件。 In a se ...
  • 可分配数组有两个用途: 您不必在编译时知道数组的大小。 您可以最小化内存使用。 如果没有可分配的数组,你将不得不选择足够大的静态数组大小来适应任何可能的大小,这意味着在大多数情况下,你将使用比必要更多的内存。 如果您错误判断了可能的大小,则需要更改代码并重新编译。 静态数组在整个持续时间内也会占用它们的内存,因此对于主程序中的数组来说,这将是整个运行时间。 为了最大限度地减少内存使用,可分配数组可以(也应该)被释放,如果你不再需要它们的话。 (在可分配数组之前,您可以使用EQUIVALENCE语句生成不同的 ...

相关文章

更多

最新问答

更多
  • sp_updatestats是否导致SQL Server 2005中无法访问表?(Does sp_updatestats cause tables to be inaccessible in SQL Server 2005?)
  • 如何创建一个可以与持续运行的服务交互的CLI,类似于MySQL的shell?(How to create a CLI that can interact with a continuously running service, similar to MySQL's shell?)
  • AESGCM解密失败的MAC(AESGCM decryption failing with MAC)
  • Zurb Foundation 4 - 嵌套网格对齐问题(Zurb Foundation 4 - Nested grid alignment issues)
  • 湖北京山哪里有修平板计算机的
  • SimplePie问题(SimplePie Problem)
  • 在不同的任务中,我们可以同时使用多少“上下文”?(How many 'context' we can use at a time simultaneously in different tasks?)
  • HTML / Javascript:从子目录启用文件夹访问(HTML/Javascript: Enabling folder access from a subdirectory)
  • 为什么我会收到链接错误?(Why do I get a linker error?)
  • 如何正确定义析构函数(How to properly define destructor)
  • 垂直切换菜单打开第3级父级。(Vertical toggle menu 3rd level parent stay opened. jQuery)
  • 类型不匹配 - JavaScript(Type mismatch - JavaScript)
  • 为什么当我将模型传递给我的.Net MVC 4控制器操作时,它坚持在部分更新中使用它?(Why is it that when I pass a Model to my .Net MVC 4 Controller Action it insists on using it in the Partial Update?)
  • 在使用熊猫和statsmodels时拉取变量名称(Pulling variable names when using pandas and statsmodels)
  • 如何开启mysql计划事件
  • 检查数组的总和是否大于最大数,反之亦然javascript(checking if sum of array is greater than max number and vice versa javascript)
  • 使用OpenGL ES绘制轮廓(Drawing Outline with OpenGL ES)
  • java日历格式(java Calendar format)
  • Python PANDAS:将pandas / numpy转换为dask数据框/数组(Python PANDAS: Converting from pandas/numpy to dask dataframe/array)
  • 如何搜索附加在elasticsearch索引中的文档的内容(How to search a content of a document attached in elasticsearch index)
  • LinQ to Entities:做相反的查询(LinQ to Entities: Doing the opposite query)
  • 从ExtJs 4.1商店中删除记录时会触发哪些事件(Which events get fired when a record is removed from ExtJs 4.1 store)
  • 运行javascript后如何截取网页截图[关闭](How to take screenshot of a webpage after running javascript [closed])
  • 如何使用GlassFish打印完整的堆栈跟踪?(How can I print the full stack trace with GlassFish?)
  • 如何获取某个exe应用程序的出站HTTP请求?(how to get the outbound HTTP request of a certain exe application?)
  • 嗨,Android重叠背景片段和膨胀异常(Hi, Android overlapping background fragment and inflate exception)
  • Assimp详细说明typedef(Assimp elaborated type refers to typedef)
  • 初始化继承类中不同对象的列表(initialize list of different objects in inherited class)
  • 使用jquery ajax在gridview行中保存星级评分(Save star rating in a gridview row using jquery ajax)
  • Geoxml3 groundOverlay zIndex(Geoxml3 groundOverlay zIndex)