My question is very simple for jquery lovers, but hard for me. I have simple a href tag with data atrribute included.
<a href="#/one" data-menu-button="menu1" class="button">menu 1</a>
<a href="#/two" data-menu-button="menu2" class="button">menu 2</a>
// etc
Also i have very simple ajax call script.
$(".button").click(function(){
$.ajax({url: "test.php", success: function(result){
$(".page").html(result);
}});
});
My question:
How can i replace ajax url with clicked button data atrribute? For example, at the moment, as you can see, i have url: "test.php". What i need, is to change test to data atrribute (for example: menu1), but keep .php extension. I need that script finds clicked data atrribute, and replace it with test. Maybe $(this) would work?
Thanks for any answers, and sorry for bad english.