AJAX post - {"readyState": 0, "responseText": "," status ": 0," statusText ":" error "}

I have this javascript, but it does not work: the following error appears: {"readyState":0,"responseText":"","status":0,"statusText":"error"} This script is included in the web page of my site, which is located in a subdirectory of the site.

From my debugging, I don’t understand where the error might come from ... (since I’m exactly the same for the index page of my site with a different javascript that looks almost the same)

$(document).ready(function() {
    //if submit button is clicked
    $('#filterbtn').click(function () {        

        //Get the data from all the fields
        var a = JSON.stringify( $("#multiselect").val() );
        var b;
        if ($('#b').prop('checked')) {
            b = 0;
        } else {
            b = 1;
        }
        var c = JSON.stringify($("#Sliderstart").slider("value"));
        var d = JSON.stringify($("#Sliderend").slider("value"));

        //organize the data properly
        var data = 'b=' + b + '&c=' + c + '&d=' + d + '&a=' + a;

        //start the ajax
        $.ajax({
            url: "./filter.php", 
            type: "POST",         
            data: data, 
            crossDomain: true,  
            cache: false,
            success: function (html) {                  
                document.getElementById("message").innerHTML=html;                              
            },
            error: function (e) {
                alert(JSON.stringify(e));
            }        
        });
        return false;
    });     
 });  

Thanks guys!

Greetings

0
source share
1 answer

This is the error you get when you request a URL that does not exist.

:

url: "./filter.php"

:

url: "/PATH_TO_FILTER/filter.php"
+1

Source: https://habr.com/ru/post/1621836/


All Articles