Reputation: 309
I'm calling a REST Server via a simple function:
$(document).on('click', '#test', function(e){
e.preventDefault();
var name = $(this).data('name');
var path = $(this).data('path');
window.location = "http://localhost:80/server/api/v1/files/" + name;
});
How can I pass aditional data (eg. the path) to my server so that I would be able to grab it in the php request?
public function show($request, $response, $args)
{
// $request contains the path
}
Upvotes: 0
Views: 80
Reputation: 284
in Jquery you can you use ajax
$(document).on('click', '#test', function(e){
e.preventDefault();
var name = $(this).data('name');
var path = $(this).data('path');
$.ajax({
'url' : 'http://localhost:80/server/api/v1/files/',
'method' : 'POST',
'data' : {
'name' : name,
'path' : path
},
success(function(data){
console.log("Sent data");
})
});
});
Upvotes: 1