Memochipan
Memochipan

Reputation: 3465

jQuery-Prototype no conflict and correct syntax

I want to know how I need to write the line $j('#'+divRes).html()=datos; in order to work properly in a jquery-protype environment. I obtain the error: invalid assignment left-hand side

function tx_oriconvocatorias_formPost_init(divRes) {
    var $j = jQuery.noConflict();
    $j.ajax({
            type: 'GET',
            data: 'eID=ori_convocatorias_formPost',
            success: function(datos){
                $j('#'+divRes).html()=datos;
            },
        });
}

Thanks in advance.

Upvotes: 1

Views: 458

Answers (4)

Andrew
Andrew

Reputation: 13853

To set the html using jQuery the command is,

$j('#'+divRes).html(datos);

.html() returns the current html, which you are trying to set, which causes the error

Upvotes: 2

James Montagne
James Montagne

Reputation: 78690

This has nothing to do with prototype, you can't assign to that. You want to do this:

$j('#'+divRes).html(datos);

Upvotes: 2

meder omuraliev
meder omuraliev

Reputation: 186662

.html(datos) is what you want.

Upvotes: 3

Mrchief
Mrchief

Reputation: 76228

Simply change it to $j('#'+divRes).html(datos);

In jQuery, to read the html, use var str = $('#id').html() and to assign, .html('[html string]')

Upvotes: 3

Related Questions