There is a code:

<span class="word" data-wv="Able"> Able </span> <span class="word" data-wv="apple"> apple </span> <span class="word" data-wv="and"> and </span> 

How do you click on one of the words to transfer its value data-wv in get request?

    1 answer 1

     $('span').click(function() { var e = this; $.ajax({ url: 'url', type: "GET", data: {wv: $(e).attr('data-wv')}, // или $(e).data('wv'), или $(e).data().wv success: function() { } }); }); 
    • @ Alexey Shimansky, thank you, corrected) - Yuri
    • @ Alexey Shimansky. And success is the answer from the server? - Roman Kravets
    • one
      @RomanKravets, yes - Yuri
    • @Yuri Ie in success, I write what should be done after receiving the answer? (I have return newWord on my server) - Roman Kravets
    • one
      @RomanKravets, yes. There is still something to be done before the response and if the request returned an error - Yuri