weixin_33714884 2018-11-22 15:42 采纳率: 0%
浏览 19

php ajax返回假问题

I am using the following ajax function

function validatec()
{
    var coupon = jQuery('#validateC').val();
    var data = "coupon="+coupon;

        $.ajax({
            type      : 'POST', //Method type
            url       : 'https://sainicomputers.co.in/exam/index.php/login/test/', //Your form processing file URL
            data      : data, 
            async : false, 
            success: function(msg) {
                if(msg > 0)
                {

                }
                else
                {
                    alert("Please enter a valid Coupon Code");

                }
                 return false; 

            }

        });
}

What I want to do is that when the result is received from ajax call then I dont want to load the page. but this code is not working how can I do this ?

  • 写回答

2条回答 默认 最新

  • perhaps? 2018-11-22 15:47
    关注

    Your code not showing that there is a cause to page refresh, i think that you are calling the ajax when you click o button of type 'submit', if yes, you have to change the type from submit to button and in your success reponse you have to add somthing like:

    jQuery('#form').submit();
    
    评论

报告相同问题?