I am rendering my views in html
and having my backend api in laravel
. After the user logs in from cloudapp.azure.com/welcome.html, my script cloudapp.azure.com/js/script2.js sends the users password to my Laravel Controller;
//cloudapp.azure.com/js/script2.js
if(error_username == false && error_password == false){
var details = [$("#username1").val(),$("#password1").val()];
var url = "http://depressionapp1.westeurope.cloudapp.azure.com/index.php/";
$.ajax({
url: url,
type: 'POST',
data: {dataname: details},
success: function(result){
//THIS IS WHERE I AM HAVING PROBLEMS
location.href = "http://depressionapp1.westeurope.cloudapp.azure.com/welcome1.html";
/* or
var url1 = "http://depressionapp1.westeurope.cloudapp.azure.com/" + result;
$.get(url1);*/
}
});
My Controlller from route url cloudapp.azure.com/index.php/ handles the request and returns a string 'welcome.html' as required.
//UserController@postLogin works fine and returns 'welcome.html'
public function postLogin(Request $request){
$result = DB::table('users')->select('user_id')->where('username', $request['username'])->get();
$user = $result[0];
$val = '';
if(Auth::attempt(['username' => $request['username'], 'password' => $request['password']])){
$count = Answer::where('user_id', $user->user_id)->where('level', '<>', NULL)->count();
if($count){
return redirect()->route('checkLevel');
}else{
$val = 'welcome1.html';
}
}
$data = array('page' => $val, 'id' => $user->user_id);
return response($val);
}
Now because Laravel's url route processing this return of 'welcome.html' is cloudapp.azure.com/index.php/ it always seems to stay in this url and upon success on my ajax call, I want to redirect to a html page of cloudapp.azure.com/welcome1.html ie. 'cloudapp.azure.com' + result(wich is 'welcome.html').
I have tried following
$.ajax({
url: url,
type: 'POST',
data: {dataname: details},
success: function(result){
//THIS IS WHERE I AM HAVING PROBLEMS
location.href = "http://depressionapp1.westeurope.cloudapp.azure.com/welcome1.html";
/* or
var url1 = "http://depressionapp1.westeurope.cloudapp.azure.com/" + result;
$.get(url1);*/
}
But I seem to be stuck on Laravel's route and I cannot redirect.