我有mouseenter获取ajax请求的事件链接,我想获取$(this)链接的选择器并获取属性。我正在context为AJAX回调设置ajax。
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 ','');
}
})
});
但是我得到这个错误
Uncaught TypeError: Cannot read property 'replace' of undefined
我有mouseenter获取ajax请求的事件链接,我想获取$(this)链接的选择器并获取属性。我正在context为AJAX回调设置ajax。
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 ','');
}
})
});
但是我得到这个错误
Uncaught TypeError: Cannot read property 'replace' of undefined
的HTML