Results 1 to 4 of 4

Thread: trigger after previous function finish

  1. #1
    Join Date
    Jan 2008
    Posts
    441
    Thanks
    67
    Thanked 4 Times in 4 Posts

    Default trigger after previous function finish

    what is the best way to trigger a ajax call after the post happens?
    this is what i have
    Code:
    function ajaxCall(name, prodid){
    	$.ajax({
    		type: "POST",
    		url: "shortList.php",
    		data: ({'name':name, 'prodid':prodid }),
    		success: function(msg){ 
    			$('#listColumn').html(msg); 
    		}
    	});
    }
    
    $("#output a").click(function () {
    
    	var name = $(this).text();
    	var prodid = $("#prodid").val();
    
    	$.post("class/i.Name.php", { name: name, prodid: prodid },
    	function(data){
    		$("#listColumn").html(data);
    	});
    
    	ajaxCall(name, prodid);// trigger this after all the above is done
    
    });

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    I may have misunderstood the question, if so pleas clarify. But how about just moving it into the callback for the post:

    Code:
    function ajaxCall(name, prodid){
    	$.ajax({
    		type: "POST",
    		url: "shortList.php",
    		data: ({'name':name, 'prodid':prodid }),
    		success: function(msg){ 
    			$('#listColumn').html(msg); 
    		}
    	});
    }
    
    $("#output a").click(function () {
    
    	var name = $(this).text();
    	var prodid = $("#prodid").val();
    
    	$.post("class/i.Name.php", { name: name, prodid: prodid },
    	function(data){
    		$("#listColumn").html(data);
    		ajaxCall(name, prodid);// trigger this after all the above is done
    	});
    
    });
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. The Following User Says Thank You to jscheuer1 For This Useful Post:

    ggalan (06-16-2011)

  4. #3
    Join Date
    Jan 2008
    Posts
    441
    Thanks
    67
    Thanked 4 Times in 4 Posts

    Default

    yes, that did it!
    btw, how do you highlight yellow inside [code] ?

  5. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Using the mouse and/or keyboard select the text you want highlighted. Then click on the #i icon on the editor (toward the top, somewhat to the right). It will surround the selected text with:

    [ICODE]This would be highlighted but for some clever use of the text color utility to make the tags appear as normal text.[/ICODE]

    tags and thereby highlight it. You can also do it outside of a code block. Or you may if you wish type the tags manually.

    Inside a tag block it will only work for the [CODE][/CODE] and [QUOTE][/QUOTE] tags, the HTML and PHP code blocks have syntax highlighting so ignore formatting tags within their borders.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •