jquery not waiting the confirm messge, it is running all functions : I have a multi select Gridview , If a user for example selected 3 rows in the grid : name 1, name2, name3. i should show the user a popup confirm message, are you sure ?. 

the problem in jquery , it doesnt wait the confirm message, it calls all the functions. **what I want is the know the result of the message first then call the functions**


    function clickon() 
    {
    
    	var $current = $("#click_on_confirm"); 
    	var gridId = $("#Grid_id");
    	var confirmedArr = new Array;
    	confirmedArr = gridId.jqGrid('getGridParam','selarrrow');
    	var n=0;
    	var i = 0;
    
    	
    	var arrayLength = confirmedArr .length;
    	var user_id;	
    	
   	
    		if($current.is(":checked"))
            {
            var confirmMsg = "Are you sure "+ confirmedArr [i]
				console.log(user_id);
				
			// my problem is here , its not waiting till i click the confirm message	
				_showConfirmMsg(confirmMsg, ""Are you sure ?", function(confirmChoice, theArgs)
				{
				user_id = confirmedArr[i];
         i++;
         }
 confirm(confirmedArr);
        }



    function confirm(confirmedArr)
    {

    var gridId = $("#Grid_id");
    	
    		var actionSrc = jQuery.contextPath+"..............";
    		_showProgressBar(true);
	
		var param="arUser="+confirmedArr;
	   	 $.ajax({
						 url: actionSrc,
				         type:"post",
						 dataType:"json",
						 data: param,
						 success: function(data)
						 {
						  if(typeof data["_error"] == "undefined" || data["_error"] == null)
							  {		
	// something to do
							  }
						  _showProgressBar(false);
						 }
				    });
     }