$(document).ready(function () { $(".save").click(function () { sendLogin($('#usernameInput').val(), $('#passwordInput').val()); }); }); function sendLogin(login, password) { let object = { "function": 'update_website', "login": login, "password": password, }; console.log(JSON.stringify(object)); // Do not put .php in the url, otherwise the POST request will transformed in GET when server rewrites the url $.ajax({ type: "POST", url: "../ajax/write/master", data: JSON.stringify(object), dataType: "json", contentType: "application/json; charset=utf-8", complete: function (data) { alert(data.responseText); console.log(data); }, }); }