2010-04-26 60 views
0

之后没有被解释一旦我用$ .ajax函数修改了一个HTML字符串,我把它放到了一个div中... HTML是一个带有<b>标记的简单消息,但它不是由浏览器解释,我的意思是,<b>不会使文本变粗体。HTML在jQuery的.ajax函数

这里是我做的:

$.ajax({ 
    url: 'index.php?ajax=ejecutar_configuracion&id_gadget=cubrimientos', 
    cache: false, 
    success: function(html){ 
     // html = '<b>hello</b> newton' 
     $('#config_reporte').html(html).dialog({ 
      height: 300, 
      width: 500, 
      modal: true 
     }); 
    } 
}); 

正如你所看到的,我编写HTML的内容导致成模态对话框窗口。

有谁知道为什么会发生这种情况?这应该是一件容易的事情......但我一直无法正常工作。

非常感谢。

+0

如果你在你的成功函数中加入了一个javascript alert,并且输出了你的html变量的值,那么HTML看起来是否正确? (即,它是编码等) – jaltiere 2010-04-27 20:20:30

回答

0

那么......我无法使它正常工作,只用HTML。我不得不改变纯粹的HTML,并使用CSS。所以,我不使用<b>,但<span style="font-weight: bolder;">,它很好。

感谢您的阅读!

0

我想尝试添加dataType: "html"to your option s,该语句可能会对jQuery用于确定返回类型的智能猜测逻辑做一个编号。完整版:

$.ajax({ 
    url: 'index.php?ajax=ejecutar_configuracion&id_gadget=cubrimientos', 
    cache: false, 
    dataType: "html", 
    success: function(html){ 
     // html = '<b>hello</b> newton' 
     $('#config_reporte').html(html).dialog({ 
      height: 300, 
      width: 500, 
      modal: true 
     }); 
    } 
}); 

还要确保<b>没有在源头,在那里它实际上是在你的字符串,而不是返回<b>编码&lt;b&gt;

+0

感谢您的回复...不幸的是,它也没有工作... – Cristian 2010-04-27 13:36:47

0

您也可以尝试将html设置为变量,然后在数据类型字段中调用该变量。

dataToLoad: "&lt;b&gt; hello &lt;b&gt; newton"; 

$.ajax({ 
url: 'index.php?ajax=ejecutar_configuracion&id_gadget=cubrimientos', 
cache: false, 
datatype: dataToLoad, 
success: function(html){ 
    // html = '<b>hello</b> newton' 
    $('#config_reporte').html(html).dialog({ 
     height: 300, 
     width: 500, 
     modal: true 
}); 
}}); 
+0

感谢您的回复...不幸的是,它也没有工作... – Cristian 2010-04-27 13:45:16