Reputation: 617
i have the following code
eo.changeState = function(clicked_button) {
// get the selected app path
var app_path = getAppPath(clicked_button);
// get the selected app status
$.ajax({
type: 'POST',
url: '/get_app_status/' + encodeURIComponent(app_path),
context: clicked_button
})
};
and am using the route
Route::post('get_app_status/{app_path}', [
'as' => 'get_app_status',
'uses' => 'LocalDataController@getAppStatus'
]);
the problem is when i click the button, i get the following error
POST http://localhost:8000/get_app_status/%2Fmedia%2FData%2FCode%2Fproject%2Fdone%2FServiceManager 404 (Not Found)
i think its because the %, but i don't know a javascript way to fix this problem, except using a replace method, by just replace all the '/'s on javascript, then get them back with str_replace in php.
is there a valid fix on javascript ?
Upvotes: 1
Views: 136
Reputation: 845
Send the app path as POST parameter
eo.changeState = function(clicked_button) {
// get the selected app path
var app_path = getAppPath(clicked_button);
// get the selected app status
$.ajax({
type: 'POST',
data: {'app_path': app_path},
url: '/get_app_status/',
context: clicked_button
});
};
Route would be like this:
Route::post('get_app_status', [
'as' => 'get_app_status',
'uses' => 'LocalDataController@getAppStatus'
]);
Finally controller function:
function getAppStatus() {
$app_path = Input::get('app_path');
}
Upvotes: 2
Reputation: 6381
Instead of including app_path
in the URL, try sending it as a parameter:
eo.changeState = function(clicked_button) {
// get the selected app path
var app_path = getAppPath(clicked_button);
// get the selected app status
$.ajax({
type: 'POST',
data: {'app_path': app_path},
url: '/get_app_status'),
context: clicked_button
})
};
Then the route is just:
Route::post('get_app_status', 'LocalDataController@getAppStatus');
Upvotes: 2