I did not define showprayer
as a class in my CSS stylesheet.
Is that the reason this jQuery function is never called for the HTML below?
$('.showprayer').click( function(event)
{
console.log("showprayer");
$.post('/show_prayer', { 'name' : $(this).text() }, function(data)
{
//... do something with the data returned from the post
});
});
<a href="#" id="showprayer_106" class="showprayer">
<tr id="prayer_106" >
<td>Prayer <span class="prayerspn" id="prayerspn_106">106</span></td>
<td>03/19/1968</td>
</tr>
</a>
I'm trying to pass the prayerId
(in this case 106
to the /show_prayer
handler. There's probably a simpler way to do it but the easiest way I can think of is to put it inside the span above:
<span class="prayerspn" id="prayerspn_106">106</span></td>
And then pull the text ("106"
) out of the span and pass it in the $.post
call.