Transmit post data and redirect AJAX



  • I'm trying to post the data in the violin nomen.php, and after receiving the data, make a recalculation of the same violin, but when the button is pressed, the page is updated.

    JS:

        $('#listNomen').submit(function(e) {
            var filename = document.getElementById("userfile").files[0].name;
            $.ajax({
            type: 'POST',
            url: 'nomen.php',
            data: {s2: filename},
            })
           .done (function (data) {
            $.redirect('nomen.php',data);
        });
    });
    

    PHP:

    $text= $_POST['s2'];
    

    HTML:

    <div id="showNomen">
    <form id="listNomen" method="POST">
        <br>
        <label>TEST<input type="submit" value="Показать" style="position:absolute;left:12%;"></label>
    </form>
    <br>
    </div>
    


  • If you sabotage the shape, she'll be shy!

    To eliminate default action (events), use should be made preventDefault

    $('#listNomen').submit(function(e) {
        e.preventDefault();
    
    ...
    ...
    

    But that makes no sense. Right here. No use of the form itself.and it just takes data from the input, and it doesn't make sense. You can get her out of here, and the button's got to clean up the type "submit" and process the click on her.



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2