Nestor C
Nestor C

Reputation: 637

not able to write id in jquery ajax method

I want to write id in ajax success

.html:

success: function (response) {
    debugger;
    if (response.d != null) {
        $("#mycarousel").empty();
        $.each(response.d, function (i, response) {
            $("#mycarousel").append('<li id='"+response.Soid+"'><img src="../Images/DefaultPhotoMale.png" width="40" height="40" alt="image"/></li>');

        });
        jQuery('#mycarousel').jcarousel();
    }
    else {

    }
},
error: function (xhr) {

}

but i get following error:

enter image description here

Upvotes: 0

Views: 41

Answers (2)

Ni.
Ni.

Reputation: 69

You need to change your quotes like this :

 $("#mycarousel").append('<li id="'+response.Soid+'"><img src="../Images/DefaultPhotoMale.png" width="40" height="40" alt="image"/></li>');

Upvotes: 2

s.lenders
s.lenders

Reputation: 1149

Check the usage of your quotes You did:

' '"+  +"'  '

This generates an error, you used single quotes as string delimiter, then switched them around later

Change it to:

' "'+  +'"  '

Upvotes: 0

Related Questions