Starting from 3 days I try to get a solution from Ajax and PHP, I tried all the tutorials, but I can’t get a solution, I am new to Ajax, JQuery, but my question is very simple for everyone.
I developed a website using jquery and PHP, I created a menu using HTML (ul, li), so I want, if I click on a menu item, ajax should send the value of the php variable and then execute the php function, but that's it this should happen on the same page ..
Please help me solve the problems.
So far I have tried the following:
JavaScript:
<script type="text/javascript"> $("#btn").click(function() { var val = "Hi"; $.ajax ({ url: "oldindex.php", data: val, success: function() { alert("Hi, testing"); } }); }); </script>
PHP and HTML:
<input type="submit" id="btn" value="submit"> <form name="numbers" id="numbers"> <input type="text" name="number" id="number"> </form> <div id="number_filters"> <a href="abc">1</a> <a href="def">2</a> <a href="ghi">3</a> </div>
therefore, if I click on href, I should get the value of the php variable, this should happen only on the same page
jquery php
user2454281
source share