jQuery Function Runs 1 Function Per Page Load
Hi Guys,
I have this jQuery $_ POST for Create and Delete the problem is I can only activate one and I have to load the entire page before executing either of the two. How can I execute one function after the other one is done?
Now I just load the div where all the data is attached so that I don't have to load the whole page.
Here's my code.
- <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
- <script type='text/javascript'>
- $(document).ready(function(){
-
- $("#addNewVendor").click(function() {
- $.ajax({
- type: "POST",
- //dataType: "json",
- url: "create.php",
- data: {vendorName: $("#vendorName_new").val(), owner: $("#owner_new").val(), city: $("#city_new").val()},
- success: function(){
- $(this).hide();
- //$('div.success').fadeIn();
- showUsers()
-
- }
- });
- return true
- });
-
- $(".deleteBtn").click(function() {
- if(confirm('Are you sure?')){
- var $id2 = $(this).val();
- $.post("delete.php", { id: $id2 })
- .done(function(data) {
- showUsers();
- });
- }
- });
- });
- function showUsers(){
- $('#pageContent').load('read.php', function(){ $('#loaderImage').hide(); });
- }
- </script>