0
votes

hi i am trying to post some values on drop down change and fetch data form database on the base of that value and return back the ajax response . like i want to get all branches of that specific company when i change company by drop-down, branches of that specif company displayed in drop down in a specific area but i am facing 500 (Internal Server Error). Always displays i am an error in console. My jQuery is

$(".select-company").dropdown({
    onChange: function (val) {

        var CSRF_TOKEN = $('meta[name="csrf-token"]').attr('content');
        var id=val;
        var urll = "promoplan/getcity";

            $.ajax
                ({
                    type: "POST",
                    url: urll,
                    data: { company_id: id, _token: CSRF_TOKEN },
                    cache: false,
                    success: function(html)
                    {
                    console.log(html);
                    //$("#regions").html(html);
                    },
                    error: function() 
                    {
                    console.log('i am an error');
                    }
                });
    }
});

My Route is

Route::post('promoplan/getcity','PromotionPlanController@getcity');
2
post controller part also - Vision Coderz
this is what i just writen in my PromotionPlanController public function getcity(){ return Response::json("i am get city"); } - Umair Mehmood
Inspect your browser and go to network then select XHR. Then you will get details about your error. May be it occurs for your PromotionPlanController. - Mahfuz Shishir

2 Answers

2
votes

In your controller you have to incude following

use Response;
0
votes

Can you try var urll = "promoplan/getcity"; to urll = "/promoplan/getcity";