+ 1
How to send ajax request to a localhost?
I am in mobile.
6 Réponses
+ 3
$(document).ready(function() {
$("button").click(function() {
var myData = {
"name": "aName",
"pasw": "aPasw"
};
$.ajax ({
url: "myURL",
type: "POST",
data: myData
}).done(function(data) {
outputJSON = JSON.stringify(data);
console.log(outputJSON);
output = JSON.parse(outputJSON);
console.log(output.Result);
}).fail(function(data, err) {
alert("fail " + JSON.stringify(err));
});
});
});
+ 4
Using the fetch API
https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API
https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch
https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch
Kindly visit all the links and study them carefully.
The server side can be written in any language of your choice. Or you can practice with JSON placeholder API if you don't want to create a back end.
https://jsonplaceholder.typicode.com/
+ 2
The url is you webside, which will receive the request and manage it for example:
http://localhost:port/myside.php
A number of port will be only needed, if your setted port is other than 80.
+ 2
And the myside.php should be in the htdocs directory.
+ 1
Example of url plz
+ 1
For more deatails please see:
https://www.apachefriends.org/faq_windows.html