Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Oct 2010
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Noob question - how to use variables

    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

  • #2
    New to the CF scene
    Join Date
    Oct 2010
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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);

  • #3
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •