Ajax does not enter Success

Asked

Viewed 104 times

0

And I’m having a hard time in Ajax.

I have the following:

      beforeSend: function ()
      {
          $("#btnEvniar")
          .prop('disabled', true)
          .click(JaClicouProc(3,this));
      },
      success: function (resultado)
      {
          FechaDivAg();
          swal({
            title: "Sucesso!",
            text: "Helpdesk enviado com Sucesso.",
            showConfirmButton: false,
            timer:3000,
            html: true
          });

          $(".cam").each(function () {
              $(this).val('');
          });
      }

The function JaClicouProc() hangs the screen so that the user does not keep sending several helpdesks...

But it does not enter the successful part of Ajax. this function FehcaDivAg() unlock the screen.

In the target file of Ajax which is a file. php am giving a echo "true";

Does anyone know why you’re not getting into Success?

Follow function code as requested!

function JaClicouProc(qualmsg, wcam, msgopc)
{   
   if (typeof(msgopc) != "undefined")
       ShowAguarde(qualmsg, msgopc);
   else
       ShowAguarde(qualmsg);
//     ShowAguarde(qualmsg);    :MostraAguarde
   document.getElementById(wcam.id).blur();
// gab 2016-07-26. Usa a função para não processar duas vezes (a mesma do botão salvar)
   return true;
}
  • 1

    If you don’t enter Sucess it’s because you’re locking in beforeSend, it works cascading. As you said yourself, the Jaclicou function hangs, the error must be in it.

  • Puts the complete Ajax because other parameters can influence the result.

  • even returning true in function jaClose? full ajax is pretty big! put anyway?

  • You’re entering the beforeSend?

  • yes is entering.

  • 1

    Take a test: comment all beforeSend and see if you enter Success... if you enter, the problem is in beforeSend.

  • then try giving one instead of echo "true" tries to give a echo json_encode( array( 'retorno': true ))

  • good... I commented the function and it worked... the code is of the company in which I am working and I can not touch some functions... was the function Jaclicouproc really... Thank you!

  • If you can put what you have in this role to see what’s going on.

Show 4 more comments

1 answer

0


If the function beforeSend not return true, the request is aborted, as the documentation says. Do so:

beforeSend: function ()
{
    $("#btnEvniar")
      .prop('disabled', true)
      .click(JaClicouProc(3,this));
    return true;
},
  • Nice friend... now it worked perfectly... Thank you! unfortunately I was vetoed to ask more questions... Thank you all.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.