Neha Agarwal
Neha Agarwal

Reputation: 15

Ajax Jquery Call for On Submit Not Working

Despite adding the prevent default option on submit, the code is not being redirected to try.php and on submit the values are being displayed on the browser like it does by GET method. I have been on this for hours now. Kindly Help!

    $.ajax({
    url: "try.php",
    cache: false,
    type    :"POST",
    data    : {action:'John'},
    success : function( data ) {
    $("#show_here").val(data);     
                      }
           });
       });

    });

Upvotes: 0

Views: 99

Answers (2)

shilpa sree
shilpa sree

Reputation: 94

check entered url/path is correct.

$(document).ready(function(){       
    $('.ajaxform1').submit( function(e) {

        $.ajax({
            url     : "try.php",
            cache   : false,
            type    :"POST",
            data    : {action:'John'},
            success : function( data ) {
                $("#show_here").val(data);     
            }               
        });
    });     });

Upvotes: 0

aldrin27
aldrin27

Reputation: 3407

Try this if it works:

        $('.please').submit( function(e) {
        e.preventDefault();
        //var act = $("input[name='v_year_name']").val();

          $.ajax({
            url     : "try.php",
            cache: false,
            type    :"POST",
            data    : {action:'John'},
            success : function( data ) {
                     $("#show_here").val(data);     
                     }

          });

       });

Upvotes: 1

Related Questions