<script type="text/javascript" src="jquery-min.js"></script> <script type="text/javascript"> $(document).ready(function() { var $xhr = $.ajax({ url: "search.php", type: "POST", data: {id: 1, name: "Pritom Kumar"}, beforeSend: function(xhr){ xhr.setRequestHeader('X-Test-Header1', 'test-value1'); xhr.setRequestHeader('X-Test-Header2', 'test-value2'); }, dataType: "json" }).done(function(data, textStatus, jqXHR) { }).fail(function(jqXHR, textStatus, errorThrown) { alert("Failed With Reason=" + textStatus); }); setTimeout(function() { $xhr.abort(); }, 100); }); </script>
Showing posts with label ajax post. Show all posts
Showing posts with label ajax post. Show all posts
Saturday, January 14, 2017
Abort / Cancel jQuery Ajax Request Example
Friday, November 4, 2016
Angularjs ajax get or post method example from controller
app.controller('TestController', function($scope, $http) { $scope.name = "Pritom Kumar"; $scope.posts = ["a", "b"]; $http.post('lists_json', {id: 1, name: $scope.name}). success(function(response, status, headers, config) { console.log("Success=" + response); }). error(function(response, status, headers, config) { console.log("Error=" + response); }); $http.get('lists_json?id=1&name='+$scope.name+"&list="+$scope.posts). success(function(response, status, headers, config) { console.log("Success=" + response); }). error(function(response, status, headers, config) { console.log("Error=" + response); }); });
Friday, January 18, 2013
jQuery post call using ajax
jQuery.ajax({
type: "POST",
url: "http://domain.com/save_form_data",
data: jQuery("form").serializeArray(),
success: function(data) {
console.log(data);
alert("Success");
},
error: function() {
alert("Error occurred.");
}
});
Subscribe to:
Posts (Atom)