smith
smith

Reputation: 5461

call two ajax function when click

I tried to implement the following function

$(document).ready(function() {

   $("#viewresult input:button").click(function () { 
       var selectedset = document.getElementById("selectedset").value;
       $.get("EditSet.php", "selectedset="+selectedset+"", function(){
    });

    var str = $("#selectform").serialize();
    $.ajax({
               type: "POST",
               url: "editsetsphoto.php",
               data: str,
               cache: false,
               success: function(msg)
               {
                    $("#thumbnails").ajaxComplete(function(){
                        $(this).fadeIn("slow").html(msg)
                     });
               }
             });
            return false;
        }); 
  });

Is it possible to get it work when I call two ajax function send to two different php files in one click?

Upvotes: 0

Views: 984

Answers (1)

aziz punjani
aziz punjani

Reputation: 25776

Sure, since your ajax requests are independent, you don't need to utilize the callback on the get request.

$(function(){
   $("#viewresult input:button").click(function () { 
     var selectedset = $("#selectedset").val();
     $.get("EditSet.php", "selectedset="+ selectedset );

      var str = $("#selectform").serialize();
         $.ajax({
           type: "POST",
           url: "editsetsphoto.php",
           data: str,
           cache: false,
           success: function(msg)
           {
               $("#thumbnails").html(msg).fadeIn('slow');                 
           }
        });
  }); 
});

Upvotes: 1

Related Questions