Handling Inconsistent HTTP Status Codes in Ajax: 404 in Latest Chrome, 200 in Edge and Older Chrome – How to Resolve?

26 Views Asked by At

How can I address and obtain the correct status code for this Ajax code? In the latest version of Chrome, it returns a status code of 404, while in Edge and the older version of Chrome, it returns a normal 200.

<script>
        const url = 'https://www.google.com';
    
        $.ajax({
            url: url,
            dataType: "jsonp",
            cache: false,
            timeout: 10000,
            complete: function (xhr, textStatus) {
                console.log('HTTP Status Code:', xhr.status);
                console.log('Request Status:', textStatus);
            }
        });

</script>

How to Resolve?How to Resolve?

0

There are 0 best solutions below