The following code launches a GET instead of an HTTP POST request.
function AddToDatabase() { this.url = './api/add'; } AddToDatabase.prototype.postData = function(dataToPost) { $.ajax({ type: "POST", url: this.url, data: dataToPost, context: this, success: this.onSuccess }); }; var AddToDatabase = new AddToDatabase(); data = {data: 'coucou'}; AddToDatabase.postData(data);
Why and how can I get a POST?
I see in Google Chrome Inspect and Firefox. Make sure the browser sends a GET. Here from Chrome:
Request URL: http: // localhost / SAMPLE-CODES / UPDATE% 20MYSQL / api / add / Request Method: GET Status Code: 200 OK
solvable
The URL called "./api/add" was to send a message to. /api/add/index.php. It turns out that calling './api/add /index.php ' or './api/add / ' gives me a POST request.
It was just the wrong URL, but for some reason I was getting a successful GET request for '.api / add /'.
jquery ajax
tucson Aug 30 '12 at 11:29 2012-08-30 11:29
source share