When we went to use $ .ajax data exchange method in an event
$('.btn_box').click(function() { $.ajax({ type: 'post', url: '', dataType: 'json', contentType: 'application/json; charset=utf-8', async: false, success: function(res) { console.log($(this)) } }) })
At this point in the console title will be reported as the same error,
1. Because the $ .ajax () of $ (this) I have not dealt with before, and in the $ .ajax () it refers ajax jQuery object itself;
Solution:
$('.btn_box').click(function() { $.ajax({ context: this, type: 'post', url: '', dataType: 'json', contentType: 'application/json; charset=utf-8', async: false, success: function(res) { console.log($(this)) } }) })
Only you need to add a context in ajax in: this locking element to solve the current problem! ! !