I'm trying to get the "id" attribute of a tag that also calls jQuery qTips. The setup is as follows:
$('.selector').qtip({
content: {
text: 'Loading...', // The text to use whilst the AJAX request is loading
ajax: {
url: 'getInfo.php', // URL to the local file
type: 'GET', // POST or GET
async: false,
data: { id: $(this).attr('id')}, // !! PROBLEM HERE
success: function(data, status) {
// Set the content manually (required!)
this.set('content.text', data);
}
}
}
});
The caller is as such:
<a href='http://www.google.com' class='selector' id='Jerome'>Jerome</a>
but for some reason $(this).attr("id") is undefined. The qTip shows up but is blank, and the GET call shows up as not passing any data in Firebug. What am I missing?
Thanks!
Edit: also, this.attr returns "this.attr is not a function"
Try this it will solve your problem.
$('.selector').each(function(index, item){
$(item).qtip({
content: {
text: 'Loading...', // The text to use whilst the AJAX request is loading
ajax: {
url: 'getInfo.php', // URL to the local file
type: 'GET', // POST or GET
async: false,
data: { id: $(item).attr('id')}, // !! PROBLEM HERE
success: function(data, status) {
// Set the content manually (required!)
this.set('content.text', data);
}
}
}
});
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With