[jQuery] Re: Passing a variable into the $('selector') function

2008-07-03 Thread Stompfrog

msg was actually myDiv and in the end i got it to work with..

$('#'+msg)

Thanks very much for your helpful reply.

Cheers

On Jul 2, 11:16 pm, "Erik Beeson" <[EMAIL PROTECTED]> wrote:
> If msg is '#myDiv' and you have element with id="myDiv", then $(msg) will
> select it.
>
> If you think that's what you're doing and it isn't working for you, either
> your id is wrong or msg doesn't hold what you think (maybe it has a trailing
> \n?).
>
> --Erik
>
> On 7/2/08, Stompfrog <[EMAIL PROTECTED]> wrote:
>
>
>
> > Hi all,
>
> > I have a problem that I can't crack.
>
> > I have a function similar to this..
>
> >   $.ajax({
> >type: "POST",
> >url: "some.php",
> >data: "name=John&location=Boston",
> >success: function(msg){
> >  alert( "Data Saved: " + msg );
> >}
> >   });
>
> > The data that gets passed back to the function from some.php is a
> > string which is the id of the div that I want to manipulate in the
> > callback function e.g. "#myDiv".
>
> > My question is how can I get that div from the callback function using
> > the msg variable because $(msg); doesn't work and neither does $
> > ("'"+msg+"'");
>
> > Thanks in advance,
>
> > Stompfrog


[jQuery] Passing a variable into the $('selector') function

2008-07-02 Thread Stompfrog

Hi all,

I have a problem that I can't crack.

I have a function similar to this..

 $.ajax({
   type: "POST",
   url: "some.php",
   data: "name=John&location=Boston",
   success: function(msg){
 alert( "Data Saved: " + msg );
   }
 });

The data that gets passed back to the function from some.php is a
string which is the id of the div that I want to manipulate in the
callback function e.g. "#myDiv".

My question is how can I get that div from the callback function using
the msg variable because $(msg); doesn't work and neither does $
("'"+msg+"'");

Thanks in advance,

Stompfrog