Home Javascript Jquery ajax request example

Jquery ajax request example

by Shahriar Sagor

Today now in this post i would like to show you an example of Ajax request in Jquery. If you are a very fresher in jquery and laravel and you have no idea on how to work with post ajax request then bellow example can be help you. Here i will give you the example of POST ajax request also with json, we can also easily modify this example. So we can also fire GET ajax request by using this example. Now in the bellow example is a pretty simple to understand about how to work $.ajax method.

so let’s see the bellow example and can try to understand.

Example:

<html lang="en">
<head>
	<title>JQuery Ajax Demo</title>
	<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
</head>
<body>
	<button class="ajax">Click Here</button>
    <script type="text/javascript">
    	$(".ajax").click(function(){
		  $.ajax({
                        url: "{{route('asset.ssm.requisition-supply_check') }}",
			dataType: "json",
			type: "POST",
			data: {"id":"10"},
			success: function (data) {
			  alert(data);
			},
			error: function() {
			  alert('Error.');
			}
		  });
    	});
    </script>
</body>
</html>

Read Also : How to convert Object into Array in PHP?

Thanks for read. I hope it help you. For more you can follow us on facebook.

close

You may also like