javascript - How to target an element that is being clicked in a class inside ajax -
I want to target some div in a class, I use $ (this), but that does not work Does that class call from another function?
Sample code. From top to bottom, I do not know how impliment. This class seems to be targeting ".player", but not the whole class, just cling to that element Thanks. When AJAX callback is executed, By default, the execution reference of the callback method is set to Ajax setting object. You have a custom execution reference Represents the AJAX setting ($ .ajaxSettings $ .ajax Merging with the settings passed to the address). For example, by specifying a DOM element, it requests that request the complete callback of Reference for
$ (document) .on ('click', '.layer', (function) (e) {var id = $ (this) .find ('. Song_Id ') .HTML (); $ .ajax ({type: "POST", data: {data: id}, complete: function () {$ (This) .attr (' src ',' ../images/appicons / 2 / 16x16 / refresh - Red.png ')}, URL: "php / player / get_song.php"}) (function (F) {$ (' # Song_info '). Html (f)})}}
$ (this) .attr ('src', '../images / appicons / 2 / 16x16 / refresh - Red.png '),
$ (document) .on ('click' , '.layer', function (e) {var id = $ (this) .find ('. Song_Id '). Html (); $ Use context to set AJAX ({type: "POST", data: {data: id}, // callback reference execution reference: this, complete: function () {$ (this) .attr ('src ',' ../images/appicons/2/16x16/refresh - Red.png ')}, url: "html (f)})}}
Comments
Post a Comment