I am using jConfirm for confirm dialog with success.

For first time i tried to call it inside the ajax success but seems to fail.

Here is the code:

    success: function (j) {   
    if(j.status)
    {

     jConfirm('File Already exist.Are you sure you want to replace ?', 'File Exist', function(r) {
         if (r==true)
      {   }
      else 
      {  
               //code for cancel
      }
     });
    }
  }//success

The problem is that the dialog is show but does not wait for user answer and continues.

When change to classic javascript confirm everything works fine!

有帮助吗?

解决方案

jConfirm is an asynchronous method.
As you've noticed, it returns immediately, without waiting for the user to close the dialog.

You need to put all of your code in the jConfirm callback.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top