Reputation: 295
I'm using a jQuery plugin that uses a hash-url - #/page/1...5
I'm trying to get the page number and use it with PHP without reloading the page.
I tried to send it with AJAX from a javascript variable to a PHP (post) variable but it is redirecting me to another page.
$.ajax({
url: 'other_page.php',
type: "POST",
data: ({id: 1}),
success: function(data){
//
}
});
I'm trying to use the id-data (example above) in the same page where the ajax-script is. I hope someone can help me achieve this.
Upvotes: 0
Views: 759
Reputation: 466
You can get the hash with
window.location.hash
You must then tokenize it to get the number
var page = window.location.hash.split('/')[2]
You could then forward it on with ajax with
$.ajax({
url: 'other_page.php',
type: "POST",
data: ({id: page}),
success: function(data){
//
}
});
Upvotes: 1