lundi 11 janvier 2016

why there is meta tag in json response in laravel5

I confused very much. Please help me.

I have this java script code:

$(document).ready(function(e) {
    $('#requestButton').click(function(e) {
        $.ajax({
                type: "POST",
                dataType:"json",
                data:{job:'propertyCreation' },
                url: "/testajax", //Relative or absolute path to response.php file
                success: function(data)
                {
                    alert(data.responseText);

                },//success
                error:function(e){
                    alert(e.responseText);
                }
            }//ajax
        );//ajax
    });
});

Testajax function in my controller is responsible for answering to above ajax request.

public function testajax(Request $request)
{
    if ($request->isMethod('post')){
        $result=array('success'=>true,'response'=>$_REQUEST['job']);
        return json_encode($result);
    }

}

I expected that the response be

{"success":true,"response":"propertyCreation"}

but response is

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
{"success":true,"response":"propertyCreation"}

I confused why there is meta tag in json response and the result has error not success. sorry for my bad english and thank you in advance



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire