mardi 8 mars 2016

Anchor tag onClick is not working ajax using laravel 5

On my page one anchor tag is their for that anchor tag i have assigned one class named as state when i clicks on anchor tag it's not redirecting on desired page , In console i have seen my query is working. Here is my ajax

 <script>
 $(document).ready(function() {
$('a.state').click(function(event){
   event.preventDefault();
   var link = $(this).attr('id');
    //alert(link); 
        $.ajax({
           type: "GET",
           url: 'property_details/{state}',
           dataType: "json",
           data: {id: link}
        });
 });
});
</script>

this is my route

Route::get('property_details/{state}', array('as' => 'property_details', 'uses' => 'PageController@property_details'));

this is my controller

  public function property_details() {
    $filter = Input::get('id');
    $view = DB::table('property_details')
    ->leftJoin('agent_registration_details','property_details.state', '=', 'agent_registration_details.state')
    ->where('property_details.state', 'LIKE', '%' . $filter . '%')
    ->get();
        //return Response::json($view);
          //var_dump($view);
        return View::make('pages/property_details', array('row'=>$view));
    }  



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire