javascript - my ajax dont work at all? -


i have ajax function (below). trying pass input 1 page another.

it redirects me other page not pass required value.

i not understand why doesn't work expected.

i looking way this. appreciated.

  //second page        <?php       $cuit = $_post['cuit'];      ?>  <input id="act" type="text" class="form-control" value="<?php echo $cuit ?>">

function mod(id, origen) {    swal({      title: 'are sure?',      text: "you won't able revert this!",      type: 'warning',      showcancelbutton: true,      confirmbuttoncolor: '#3085d6',      cancelbuttoncolor: '#d33',      confirmbuttontext: 'yes, delete it!',      cancelbuttontext: 'no, cancel!',      confirmbuttonclass: 'btn btn-success',      cancelbuttonclass: 'btn btn-danger',      buttonsstyling: false    }).then(function() {      if (origen == "perfiles") {        $.post("api/eliminar_perfil.php", {          id: id        }, function(mensaje) {          $("#tr_" + id).remove();        });      } else if (origen == "index") {        $.ajax({          type: "post",          url: "perfiles.php",          data: {            cuit: $("#cuit").val()          },          success: function(result) {            location.href = 'http://localhost/miramonteapp/perfiles.php';          }        });      }      swal('deleted!', 'your file has been deleted.', 'success')    }, function(dismiss) {      // dismiss can 'cancel', 'overlay',      // 'close', , 'timer'      if (dismiss === 'cancel') {        swal('cancelled', 'your imaginary file safe :)', 'error')      }    })  }
<input id="cuit" type="text" class="form-control" onkeyup="searchcliente();">    <button id="btnbuscar" onclick="mod($('#cuit'), 'index');" type="button" class="btn btn-default" name="button">buscar</button>

boy, think solution simpler, don't need ajax call if want redirect param.

so replace this

 $.ajax({                type : "post",                url : "perfiles.php",                data :  {cuit: $("#cuit").val()},                success : function(result) {                 location.href = 'http://localhost/miramonteapp/perfiles.php';                }              }); 

by

 location.href = 'http://localhost/miramonteapp/perfiles.php?cuit=' +   $("#cuit").val(); 

and in destination page perfiles.php

just read param , use it, can read params in js using guide how value parameters?


Comments

Popular posts from this blog

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -

python - Error while using APScheduler: 'NoneType' object has no attribute 'now' -