0
votes
var postData = $('#postalCheckForm').serialize();
$.ajax({
    url: "check.php",
    type: "POST",
    dataType: "text",
    data: postData,          
    contentType: "application/x-www-form-urlencoded",
    success: function(responseData, textStatus, jqXHR) {
        if (responseData !== 'none') {
            window.location.href = '';
        } 

    },

    error: function(jqXHR, textStatus, errorThrown) {
        console.log(errorThrown);
    }
});

I have this JavaScript ajax call. It sends the postal code to the php script and script is returning text value with response.

It is working in Firefox and in IE as expected. But not working in webKit browsers (Chrome, Safari). Instead of get response from php script page is reloaded and this string is added to URL: ?postal_input=TEST

[SOLVED] return false to the end of js.

1
What event handler are you using? submit? if it's the case you could try to add : return false; at the end - BaNz
Yes, submit. And you are right! add return false to the end solved it. thx - antlik

1 Answers

0
votes

You have to add :

 return false;

at the end of your code to avoid your form to be submited.