Ajax giving error 302

Asked

Viewed 271 times

0

I’m calling the same Javascript functions in separate forms on the same page.

When I call the function of the first form, the function that executes an ajax is executed normally.

When calling the same function in the second form, ajax is not executed by returning error 302 Moved Temporarily.

I’m breaking my head to know why the error and so far I could not know because calling the function in the first form works normally without error.

Problem is running on the second flame in the second form, and in that second form calls the function in the same way as the first form.

$.ajax({
          url: "/busca.php",
          type:"POST",
          data: { "valor": valor, "combo" : combo, "categoria" : categoriab, "estado" : estadob, "cidade" : cidadeb, "bairro" : bairrob, "etapa" : etapa},
          cache: false,
          success: function(response) {
              var resultado = JSON.parse(response);                    
              $("#"+resultado.etapa+"").html(resultado.combo);             
          },
          error: function() {
              alert(" Não foi possível completar a solicitação! ");
          },
          complete: function() {
              //direcionar para algum lugar                    
          } 
      });
  • 1

    You can share with us the relevant sections of Forms and Function?

  • Probably the pages are in different directories. Since you use the same ajax, one correctly maps the path and the other not.

  • 1

    It would be nice [Edit] and put the server-side code

  • @Just what I said. How to do the mapping correctly so that it can work properly? One is at the root, the other is inside a folder, only works what is inside the folder. url: /.php file, reference only works for calling the file inside the folder, what is outside the folder is giving error 302

  • @jbueno code posted

No answers

Browser other questions tagged

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