ajax post call
<script>window.onload = function(){ let aData = {"profile": "developer", "to": "rashid.jorve@live.in"}; console.log(FormData); $.ajax({ type: "POST", url: "/api/saveProfile", data: JSON.stringify(aData), contentType: "application/json", success: function(){ alert("Request was successful"); } }); };
make ajax request post jquery
$.ajax({ method: "POST", url: "some.php", data: { name: "John", location: "Boston" } })
Source: api.jquery.com
ajax post
var myKeyVals = { A1984 : 1, A9873 : 5, A1674 : 2, A8724 : 1, A3574 : 3, A1165 : 5 } var saveData = $.ajax({ type: 'POST', url: "someaction.do?action=saveData", data: myKeyVals, dataType: "text", success: function(resultData) { alert("Save Complete") } }); saveData.error(function() { alert("Something went wrong"); });
ajax post request javascript
function myFunction() { var elements = document.getElementsByClassName("formVal"); var formData = new FormData(); for(var i=0; i<elements.length; i++) { formData.append(elements[i].name, elements[i].value); } var xmlHttp = new XMLHttpRequest(); xmlHttp.onreadystatechange = function() { if(xmlHttp.readyState == 4 && xmlHttp.status == 200) { alert(xmlHttp.responseText); } } xmlHttp.open("post", "server.php"); xmlHttp.send(formData); }
Source: stackoverflow.com
jquery ajax $.post with data
$.post('http://example.com/form.php', {category:'client', type:'premium'}, function(response){ alert("success"); $("#mypar").html(response.amount); });
ajax post method in jquery
$.post("demo_test_post.asp", // change demo_test_post.asp to your server route { name: "Donald Duck", city: "Duckburg" }, function(data, status){ alert("Data: " + data + "\nStatus: " + status); });