Thanks Erik. It helped! The id is inserted correctly.

But the image isn't replaced correctly.

What code should I sow you more Makisa? The other code isn't affected
with this. What do you mean?

On 22 Sep., 10:26, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> wrote:
> you concatenate a string with an object..
>
> On 22 Sep., 10:16, suntrop <[EMAIL PROTECTED]> wrote:
>
> > This is the JS code:
> > $('.makeFavorite').click(function() {
> >         $.ajax({
> >                 type: "POST",
> >                 url: "make_favorite.php",
> >                 data: "id=" + $(this.id),
> >                 success: function(msg) {
> >                         alert('Data saved: ' + msg);
> >                         $('h1 a#' + this.id + ' img').attr({src : 
> > "images/"+msg+".png"});
> >                 }
> >         });
> >         return false;});
>
> > The HTML code:
> > <h1>{$ent.firma} <a href="{$ent.id}" class="makeFavorite"
> > id="{$ent.id}" title="Save favorite"><img src="images/{if $ent.favorit
> > == 1}favorites.png{else}favorites2.png{/if}" width="16" height="16"
> > alt="" /></a></h1>
>
> > Both variables don't do what what I expect them to do. The first
> > doesn't find the correct target/id and the seccond doesn't insert the
> > image correctly. But if I write down the id and the true path it works
> > fine.
>
> > What do I have to change?
>
> > On 22 Sep., 05:42, ricardobeat <[EMAIL PROTECTED]> wrote:
>
> > > I can't get it either, what are you trying to accomplish?
>
> > > $('h1 a#' + this.id') is not logical, you first need to reference some
> > > <a> element to get it's ID, but in doing that you already wrote the
> > > ID...
>
> > > On Sep 21, 11:16 pm, FrenchiINLA <[EMAIL PROTECTED]> wrote:
>
> > > > i think your problem is this.id, you have to show the entire code in
> > > > order for us to see what does this mean. try just to add a alert for
> > > > example to see what you get for this.id
>
> > > > On Sep 21, 7:38 am, suntrop <[EMAIL PROTECTED]> wrote:
>
> > > > > HI there,
>
> > > > > I want to insert two variables into the selector and an attribute. But
> > > > > it doesn't work.
>
> > > > > $('h1 a#' + this.id + ' img').attr({src : "images/" + msg + ".png"});
>
> > > > > I looked through various tutorials but couldn't find an answer to
> > > > > this.
>
> > > > > The first variable comes from the object's (<a> element) id and the
> > > > > seccond is a response from an php script.
>
> > > > > Can somebody please help me?- Zitierten Text ausblenden -
>
> > - Zitierten Text anzeigen -

Reply via email to