How to make an ajax request for connection
source link: https://www.codesd.com/item/how-to-make-an-ajax-request-for-connection.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
How to make an ajax request for connection
I have this in my PHP code, and it currently does the login request in the same login.php page but now i want to do it with Ajax. Basically I have this in the login.php
echo '<form method="post" ><div id="login" class="login">
<label for="login">User Name</label>
<input type="text" name="logInUsername" />
<label for="Password">Password</label>
<input type="password" name="logInPassword" />
<input type="submit" value="Submit" name="submitlogin" class="button" />
</div>';
I would like to still use this but have a login_request.php or something where i can send the username and password validated and then change the <div id=login> to say you are logged in!</div>
I can do it the conventional way, with the form post .. but now I would like to try it with Ajax.
Any help will be much appreciated.
Regards
What have you tried so far? This is how I would start:
This should get you started:
HTML:
<form id="loginForm">
<div id="login" class="login">
<label for="login">User Name</label>
<input type="text" name="logInUsername" />
<label for="Password">Password</label>
<input type="password" name="logInPassword" />
<input type="button" value="Submit" id="submitlogin" class="button" />
</div>
</form>
jQuery:
$("#submitlogin").click(function() {
inputs = //grab then inputs of your form #loginform
$.ajax ({
url: "urltoyourloginphp.php",
data: inputs,
success: function() {
$("#login").html("You are now logged in!");
}
});
})
Recommend
-
25
Update note : Owen Brown updated this tutorial to Swift 4.2. He also wrote the original. Do you have a web site that shares content with an iOS app? Since iOS 9, you can connect them using univers...
-
10
Making partial web page updates by using fulfilled promises with...
-
3
AJAX Request Interceptor This is a little funky script to intercept AJAX requests and raise a simple custom event for everything else in your app to listen to. To use this, you just need to listen for a custom event named `Aj...
-
4
Pass js object with ajax request advertisements This question already has an answer here: jQuery posting valid json in reque...
-
5
How to call https url ajax request in javascript or jquery advertisements Can anybody tell How to call https url ajax request in java script o...
-
10
While sending Ajax request, sometimes you just need to get data and load to HTML element or load external script. Sometimes you need to load data and perform operation on it. That's why jQuery provides different ways to call get request....
-
11
In this article, we'll take a look at what AJAX is, why it is important, and how we can make an AJAX POST request with XHR, fetch(), and jQuery. What Is AJAX? AJAX stands for Asynchronous Java...
-
9
AJAX Form POST Request to Google App Engine Python Updated: March 02, 2015 Th...
-
10
Google pie chart with ajax request example in PHP 986 views 6 months ago PHP In this tutorial, we will go through imple...
-
11
How to check request is ajax or not in Laravel 8 445 views 7 months ago Laravel Sometime in your Laravel applicatio...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK