I want to get the value of an href using java script and then pass it to another file of php, I did the code of JS and the value return is correct, but I dont know how to get the value and pass it, thank in advance. I am new in JS
<script>
$(function(){
$('div#tabs ul li a').click(function() {
var n = $(this).attr('href');
var p=n.slice(5,6);
alert(p);
});
});
</script>
You'll need to use AJAX to pass it PHP, here's a sample AJAX call to test.php
passing your value:
$('div#tabs ul li a').click(function() {
var n = $(this).attr('href');
var p=n.slice(5,6);
alert(p);
//AJAX TIME
$.ajax({
type: 'post',
url: 'test.php'
data: {value : p}
success: function(data) {
//do something with response 'data'
}
});
});
And in your PHP, get the passed in data
$data = $_POST['value'];
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.