Php
Categories
"; if (Mysqli_num_rows ($run _query) >0) {while ($row = Mysqli_fetch_array ($run _query)) {$cid = $row [ "CAT_ID"]; $cat _name = $row ["cat_title"];//problem here echo "$cat _name"; } echo ""; }}if (Isset ($_post["brand")) {$brand _query = "SELECT * from Brands"; $run _query = Mysqli_query ($con, $brand _query); echo "Brands
"; if (Mysqli_num_rows ($run _query) >0) {while ($row = Mysqli_fetch_array ($run _query)) {$bid = $row ["Brand_i D "]; $brand _name = $row ["Brand_title"]; echo "$brand _name"; } echo ""; }}if (Isset ($_post["getproduct"])) {$product _query = "SELECT * FROM Products ORDER by RAND () LIMIT 0,9"; $run _query = Mysqli_query ($con, $product _query); if (Mysqli_num_rows ($run _query) >0) {while ($row = Mysqli_fetch_array ($run _query)) {$pro _id = $row [' Pro Duct_id ']; $pro _cat = $row [' Product_cat ']; $pro _brand = $row [' Product_brand ']; $pro _title = $row [' Product_title ']; $pro _price = $row [' Product_price ']; $pro _image = $row [' Product_image ']; echo "$pro _title $. $pro _price.00AddToCart "; }}}?>
JS $ (document). Ready (function () {cat (); Brand (); Product (); function Cat () {$.ajax ({url: ' action.php ', type: ' POST ', data: { Category:1}). Done (function (data) {//console.log (data); $ ("#get_category"). HTML (data); }); } function Brand () {$.ajax ({url: ' action.php ', type: ' POST ', data : {brand:1},}). Done (function (data) {//console . log (data); $ ("#get_brand"). HTML (data); }); } function product () {$.ajax ({url: ' action.php ', type: ' POST ', Da TA: {getproduct:1},}). Done (function (data) {// Console.log (data); $ ("#get_producT "). HTML (data); }); }//Use the delegate () method. On cannot get $ ("body"). Delegate (". Category", "click", Function () {alert (123); })//$ (". Category"). On ("click", Function (event) {//alert (13); // });})
I use on the method why click No response? And delegate has it? Is it because this class is written on PHP and on cannot be read? Or what?
Reply content:
Php
Categories
"; if (Mysqli_num_rows ($run _query) >0) {while ($row = Mysqli_fetch_array ($run _query)) {$cid = $row [ "CAT_ID"]; $cat _name = $row ["cat_title"];//problem here echo "$cat _name"; } echo ""; }}if (Isset ($_post["brand")) {$brand _query = "SELECT * from Brands"; $run _query = Mysqli_query ($con, $brand _query); echo "Brands
"; if (Mysqli_num_rows ($run _query) >0) {while ($row = Mysqli_fetch_array ($run _query)) {$bid = $row ["Brand_i D "]; $brand _name = $row ["Brand_title"]; echo "$brand _name"; } echo ""; }}if (Isset ($_post["getproduct"])) {$product _query = "SELECT * FROM Products ORDER by RAND () LIMIT 0,9"; $run _query = Mysqli_query ($con, $product _query); if (Mysqli_num_rows ($run _query) >0) {while ($row = Mysqli_fetch_array ($run _query)) {$pro _id = $row [' Pro Duct_id ']; $pro _cat = $row [' Product_cat ']; $pro _brand = $row [' Product_brand ']; $pro _title = $row [' Product_title ']; $pro _price = $row [' Product_price ']; $pro _image = $row [' Product_image ']; echo "$pro _title $. $pro _price.00AddToCart "; }}}?>
JS $ (document). Ready (function () {cat (); Brand (); Product (); function Cat () {$.ajax ({url: ' action.php ', type: ' POST ', data: { Category:1}). Done (function (data) {//console.log (data); $ ("#get_category"). HTML (data); }); } function Brand () {$.ajax ({url: ' action.php ', type: ' POST ', data : {brand:1},}). Done (function (data) {//console . log (data); $ ("#get_brand"). HTML (data); }); } function product () {$.ajax ({url: ' action.php ', type: ' POST ', Da TA: {getproduct:1},}). Done (function (data) {// Console.log (data); $ ("#get_producT "). HTML (data); }); }//Use the delegate () method. On cannot get $ ("body"). Delegate (". Category", "click", Function () {alert (123); })//$ (". Category"). On ("click", Function (event) {//alert (13); // });})
I use on the method why click No response? And delegate has it? Is it because this class is written on PHP and on cannot be read? Or what?
Use on for dynamically generated elements
$('body').on('click','.category' , function() { alert(123); })
Before you use a new API, you should fully understand its usefulness through documentation.