javascript - All buttons in list returning same ID -


I have several buttons in one line, with all classes add-btn . When you click on one, I want to login the ID of my encoding span. However, what do I know is that all the buttons are logged in the first add-btn in the list.

  $ ('add-btn') ('id'); $ .ajax ({type: "post", url: "http: //www.domain.com/includes/follow.php", data: {id: id, shop_name: shop_name}, success: function (data) { Console.log (data);}});});  

follow.php:

  $ shop_name = $ _POST ['shop_name']; Var_dump ($ shop_name);  

change $ ('add-btn') $ (this) inside click signaling.

  $ ('add-btn'). Click (function () {var shop_name = $ (this) .classest ('span'). Attr ('id'); $ .ajax ({type: "post", url: "http: //www.domain .com / include / follow.php ", data: {id: id, shop_name: shop_name}, success: function (data) {console.log (data);}});});  

What you are currently doing is the first .add-btn id.


Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -