tags:

views:

50

answers:

3

Hello there...

Once I have retrived an HTML string with the $.ajax function I put it into a div... the HTML is a simple message with a <b> tag, but it's not being interpreted by the browser, I mean, the <b> is not making the text bold.

Here is what I do:

$.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
        });
    }
});

As you can see, I'm writing the content of the HTML result into a modal dialog window.

Does anybody know why is this happening? This should be something easy to do... but I haven't been able to make it work properly.

Thank you so much.

A: 

I'd try adding dataType: "html" to your options, that statement may do a number on the intelligent guessing logic jQuery uses to determine the return type. The full version:

$.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
        });
    }
});

Also make sure that <b> isn't encoded at the source, where it's actually returning &lt;b&gt; in your string instead of <b>.

Nick Craver
Thanks for your reply... unfortunately, it didn't work either...
Cristian
A: 

You could also try setting your html in as a variable, and then call the variable in the datatype field.

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
 });
}});
Matt Nathanson
Thanks for your reply... unfortunately, it didn't work either...
Cristian
A: 

Well... I was not able to make it work properly with just HTML. I had to change the pure HTML, and use CSS. So, I'm not using <b> but <span style="font-weight: bolder;"> and it works nice.

Thanks for reading!

Cristian