Today I am facing a strange issue that I never faced before. My ajax call is returning response with 200 status but somehow it always trigger error event instead of success. This is what I am doing
$.ajax({
        type: "GET",
        url: "swap.php",
        data: "key=dbdcd39f0f8f5077e7308f3d3d5d8cac&code="+$("#code").val(),
        contentType: 'application/json; charset=utf-8',
        dataType:"json",
        beforeSend: function() {
                $("#msg").html("<img src='imgs/loading_circle.gif'/>");
        },
        success: function(result){
                alert(result);
        },
        error: function(xhr,status,error){
            alert(error.Message); // receiving Undefined message
        }
    });
PHP code of swap.php
<?php
header('Content-Type: application/json');
$resp["data"]="Record updated successfully";
print json_encode($resp);
?>
This is the response which I get when directly put the url in address bar
Below is the screenshot of chrome's network tab


 
     
    