Well... I didn't know how to ask question so here is the explanation.
I am using Laravel 5.3 and I have a register view
it's route are of Auth::route
I am sending an AJAX request to a different script that is placed in
public/scripts/
But when it is sent this is the error I am getting
NotFoundHttpException in RouteCollection.php line 161:
this clearly means that there have to be a route given I know but I am confused what to add in the Route
in web.php
My suggestion was Route::get('/scripts/{scriptname}');
This didn't work and this is the AJAX request.
$(document).ready(function()
{
$("#username").blur(function(){
//$(this).css("background-color", "red");
var username = $(this).val();
$.ajax(
{
url: '../scripts/check_user_username.php',
method: 'POST',
data: {"username":username},
success: function(data)
{
console.log(data);
}
});
});
});
check_user_username.php
$username = trim(preg_replace('/ +/', ' ', preg_replace('/[^A-Za-z0-9 ]/', ' ', urldecode(html_entity_decode(strip_tags($_POST['username']))))));
$stmtcheckusername = $mysqli->prepare("SELECT username FROM users WHERE username LIKE ?");
$stmtcheckusername->bind_param("s", $username);
$stmtcheckusername->execute();
$stmtcheckusername->bind_result($username_from_db);
$stmtcheckusername->fetch();
$stmtcheckusername->close();
echo $username_from_db;
What I am doing is that when username is entered and user goes to different textbox then it checks whether the username is already in the database or not.
This guy has given a detail to how to send AJAX request to controller
http://stackoverflow.com/questions/41853301/how-to-add-routes-for-external-scripts-in-laravel