www.webdeveloper.com
Results 1 to 2 of 2

Thread: HTML 5 data attribute with ajax request

  1. #1
    Join Date
    Feb 2012
    Posts
    102

    Question HTML 5 data attribute with ajax request

    I am writing an ajax request and I want to use information appended to the html5 data attribute and attach that as a name-value pair for a $_GET request. I know how to set up the ajax request I just cant figure out how to get the value from the html data attribute to a variable in javascript. Here is an example of a link that I have set up with a data attribute that I want to use when clicked in my ajax request.
    Code:
    <a href="hotels.php" id="hr" data-state_hr="5" title="Hotels">Hotels</a>
    Owner of Reality TV Addict
    Publisher of Strategies for Stretching Your Income (ebook)
    CEO and Founder of Sport Directions
    Follow me at @RealityTV_Forum

  2. #2
    Join Date
    Nov 2010
    Posts
    1,083
    Code:
    document.getElementById("hr").getAttribute("data-state_hr");

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles