Hello,
I need to get a var from li when user clicks on it...the list is created in php and i want to send the variable to my other php document using ajax.. i am new to jquery and i do not know how to get the variable..
for example if my php generated list looks like:
Indianapolis
Los Angeles
when user click on Los Angeles the Jquery takes it into a var city.
- <?php
- echo '<li class="list-unstyled">'.$city.'</li>';
- }
and my jquery is:
- #(document).ready(function () {
- $("li").click(function){
- var city = $(this);
- $.ajax({
-
- type:"POST",
- url:"json.php",
- data:"city",
- dataType:"json",
-
- });
- };
- })
Can you guys tell me why is not working? Is my approach not good?