I have event mouseenter
link with get ajax request, I want to get selector $(this)
of link and get attribute. I'm use context
of setting ajax for AJAX callback.
jQuery(document).ready(function($) {
var request;
$('a[rel="bookmark"]').mouseenter(function() {
// other stuff
request = $.ajax({
dataType: "JSON",
url: '<?php echo admin_url("admin-ajax.php"); ?>',
data: {"action": "our_ajax_function", "id": dataId},
context: $(this).parent().get(0),
success: function(data){
// other stuff
var gettitle = $(this).attr('data-title').replace('Permanent Link to ','');
}
})
});
But I get this error
Uncaught TypeError: Cannot read property 'replace' of undefined
I have event mouseenter
link with get ajax request, I want to get selector $(this)
of link and get attribute. I'm use context
of setting ajax for AJAX callback.
jQuery(document).ready(function($) {
var request;
$('a[rel="bookmark"]').mouseenter(function() {
// other stuff
request = $.ajax({
dataType: "JSON",
url: '<?php echo admin_url("admin-ajax.php"); ?>',
data: {"action": "our_ajax_function", "id": dataId},
context: $(this).parent().get(0),
success: function(data){
// other stuff
var gettitle = $(this).attr('data-title').replace('Permanent Link to ','');
}
})
});
But I get this error
Uncaught TypeError: Cannot read property 'replace' of undefined
HTML
<ul>
<li>
<a href="http://localhost/area-no-kishi/" rel="bookmark" data-title="Permanent Link To Area no Kishi" data-id="4126" target="_blank">Area no Kishi </a>
</li>
<li>
<a href="http://localhost/aria-the-scarlet-ammo-hidan-no-arai/" rel="bookmark" data-title="Permanent Link To Permanent Link to Aria the Scarlet Ammo ( Hidan No Aria )" data-id="1081" target="_blank">Aria the Scarlet Ammo ( Hidan No Aria ) </a>
</li>
</ul>