...

View Full Version : jQuery Noob question - how to use variables



tmoullet
11-03-2010, 10:14 PM
Hello,

I have these two lines of code:

var initials = $("#initials").val();

$.get('/ajax/shelf_section.php?shelf_id=<?php echo $shelf['id']; ?>&initials=intitials');

I would like to pass in the variable defined in the first line, initials, as the get parameter at the end of the second line.

How do I do that...?

Thanks,
Tom

tmoullet
11-03-2010, 10:50 PM
Nevermind. I figured it out. Thanks!

Code in case you were wondering:

var initials = $("#initials").val();

var query = '/ajax/shelf_section.php?shelf_id=<?php echo $shelf['id']; ?>' + "&initials=" + initials;

$.get(query);

oesxyl
11-03-2010, 10:57 PM
it's not so simple, :) sometime you need to encode values. The simplest way is to use param:

http://api.jquery.com/jQuery.param/

best regards



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum