SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

  1. #1
    SitePoint Addict
    Join Date
    Jun 2006
    Posts
    251
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Cannot pass parameter to ajax post

    Hi folks,

    I'm trying to pass a parameter to my ajax page, but not having much luck.

    Code:
        
    
    // here is my fancybox script which the eventid shows fine.
    
        var fancyContent = ('<div class="header">approve booking for event id'  + eventid + '<a href="#" class="approve" id="' + eventid + '">yes</a><a href="#" class="approve">no</a></div>');
        $.fancybox({
            content: fancyContent
                });    
    
    // get event id from link clicked
    
    var getid = $('.approve').attr('id');
    
    // my alert here displays the id fine
    
    alert(getid);
    
    // I then begin my click function passing the getid as a parameter
    
    $('.approve').click(function(calEvent, jsEvent, view, getid){
    
    // my alert here is ALWAYS undefined, any ideas?
    
    alert(getid);
    Any help much appreciated, I just cannot seemto pass the ID.

  2. #2
    SitePoint Wizard Stomme poes's Avatar
    Join Date
    Aug 2007
    Location
    Netherlands
    Posts
    10,278
    Mentioned
    50 Post(s)
    Tagged
    2 Thread(s)
    What do you get if it's
    Code:
    $('.approve').click(function() {
      var getid = $(this).attr('id');
      alert(getid);
    });
    ?

    Just to check that yeah, it can be grabbed?
    If your click function is within a function describing the other variables, the click function would have access to them. Then inside the .click function you could have a .post with all the others.

  3. #3
    SitePoint Addict
    Join Date
    Jun 2006
    Posts
    251
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Stomme poes View Post
    What do you get if it's
    Code:
    $('.approve').click(function() {
      var getid = $(this).attr('id');
      alert(getid);
    });
    ?

    Just to check that yeah, it can be grabbed?
    If your click function is within a function describing the other variables, the click function would have access to them. Then inside the .click function you could have a .post with all the others.
    Many thanks! Its working now


Bookmarks

Posting Permissions

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