“jquery ajax post json” Code Answer’s
If you are not familiar with ajax, It is a program in which data with the server and webpage is updated in the absence of refreshing and reloading the whole page. the various kinds of text and posts such as HTML, XML, and JSON can be requested from the remote server By using the jQuery ajax method. The get and post method which is used by it is also HTTP protocol.
In short, it helps to deliver the external data straight into the whole webpage without refreshing and reloading. While JSON negotiates the HTML document just like the JavaScript library.
send json post ajax javascript
$.ajax({
url: 'users.php',
dataType: 'json',
type: 'post',
contentType: 'application/json',
data: JSON.stringify( { "first-name": $('#first-name').val(), "last-name": $('#last-name').val() } ),
processData: false,
success: function( data, textStatus, jQxhr ){
$('#response pre').html( JSON.stringify( data ) );
},
error: function( jqXhr, textStatus, errorThrown ){
console.log( errorThrown );
}
});
jquery post json example
<script type="text/javascript">
function send() {
var person = {
name: $("#id-name").val(),
address:$("#id-address").val(),
phone:$("#id-phone").val()
}
$('#target').html('sending..');
$.ajax({
url: '/test/PersonSubmit',
type: 'post',
dataType: 'json',
contentType: 'application/json',
success: function (data) {
$('#target').html(data.msg);
},
data: JSON.stringify(person)
});
}
</script>
jquery post
$.post( "test.php", { name: "John", time: "2pm" })
.done(function( data ) {
alert( "Data Loaded: " + data );
});
In these Code answers we have provided you with how to send JSON post ajax javascript, jquery post JSON with an example, and jquery post.
Thank you for visiting this page. If you find any difficulty regarding any question, describe it in the comment box.