0

How to call some PHP file in Laravel 5.1.

I have to see of that PHP file echo.

Here is the Javascript codes

<script>
$(document).ready(function(){
    $('#example').DataTable({
        "processing": true,
        "serverSide": true,
        "ajax": 'processing.php'
    });
});
</script>
1
  • I am assuming you are trying to populate your Jquery Datatables, in that case did you define route for processing.php? Please share it. Commented Nov 6, 2015 at 8:05

1 Answer 1

1

Hope you can write a route controller for that php file and call the route method in Javascript.

For example, Destination file: processing.php

Create a Route like this.

Route:get('processing', ['as=>'processing', 'uses'=>'ProcessingController@index']);

create a new controller with name ProcessingController.php,

[to create a controller in command : php artisan make:controller ProcessingController]

Inside the file add the business logic in index().

Now you can call the

<script>
$(document).ready(function(){
  var processing = '<?php echo URL::route('processing') ?>';
    $('#example').DataTable({
        "processing": true,
        "serverSide": true,
        "ajax": processing
    });
});
</script>
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you! it is so useful.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.