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.

  $ (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)})}}   

From top to bottom, I do not know how impliment.

  $ (this) .attr ('src', '../images / appicons / 2 / 16x16 / refresh - Red.png '),   

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

  $ (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)})}}   

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

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -