laravel: cannot reach controller via route

Discussion for various published PHP frameworks, including Zend Framework, CodeIgniter, Kohana, CakePHP, Yii, Symfony, and others.

Moderator: General Moderators

Post Reply
publicGenome
Forum Contributor
Posts: 110
Joined: Thu Apr 16, 2015 7:55 am

laravel: cannot reach controller via route

Post by publicGenome »

Hi There,
I'm new to web development. I've an existing application, to which no active developer is there. Legacy code is wrapped in a laravel framework.
Laravel version 4.2
php version 5.5
OSX 10.9

I want data to be loaded in my jqgrid. I call from javascript. Get method. I can reach to route from it, however after that, I don't see myself moving ahead. No error, nothing.

My js code looks like:

Code: Select all

$(document).ready(function () {
	
	$("#grid_illumina").jqGrid({
		
		url:'illumina_xhr_get_data',
		datatype: "json",
		mtype: "GET",
		jsonReader: {
		    repeatitems: false,
		    id: "",
		    root:  function (obj) {
		        return obj;
		    },
		    records: function (obj) {
		        return obj.length;
		    },
		    page: function () {
		        return 1;
		    },
		    total: function () {
		        return 1;
		    }
		},
		
		colNames:['study','Sample Name','Forward Primer','Reverse Primer'],
        colModel :[ 
                   {name:"study",sortable: true}, 
                   {name: "sample_name",sortable: true},
                   {name: "forward_primer",sortable: true},
                   {name: "reverse_primer",sortable: true}
                   ],
                rowNum:10, //this sets the default row in the pager
		
            caption:"jqGrid Illumina", //title of the grid
			pager: '#pager_illumina',	
   			shrinkToFit : false,
   	        rownumbers: true, //row numbers on left
   	        multiselect: true, //check box
   			height: '400', //height: 'auto',
   			width: '1100',
   			gridview: true,			
   			viewrecords:true, // this is for the View 1 - 8 of 8 \m/
   			sortorder:"asc", //asc 
   			autoencode: true, //don't know
   			sortable:true, //sort
   			loadonce: false, //loadonce is must
   			rowList:[3,6,9], //drop down
   			page: 1,
   			rowNum: 3
	});
URI - illumina_xhr_get_data

My routes:

Code: Select all

Route::group(['prefix' => 'illumina', 'namespace' => 'Controllers\\illumina'], function() {
	
	Log::info(Request::path()); //$uri = Request::path();
	
	Route::get('illumina_xhr_get_data','mainIllumina@testAjax');
		
});
My mainIllumina looks like:

Code: Select all


<?php namespace Controllers\illumina;
use Log;

class mainIllumina extends \BaseController {

	public function testAjax(){
               echo "haha"; //cannot reach 
		Log::info("In the function of ajax");
	}
}
?>
I do not reach this function.
If I do it from the browser too, cannot reach function.
Any help or guidance shall be highly appreciated.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: laravel: cannot reach controller via route

Post by Celauran »

You've got illumina as a prefix to the route group, but your URL doesn't start with illumina/
publicGenome
Forum Contributor
Posts: 110
Joined: Thu Apr 16, 2015 7:55 am

Re: laravel: cannot reach controller via route

Post by publicGenome »

Celauran wrote:You've got illumina as a prefix to the route group, but your URL doesn't start with illumina/
Hi Celauran,
Thanks for your reply.

But I'm able to see Log::info with the URI.
Also, my below code isn't working:

Code: Select all

	Route::get('illumina_xhr_get_data', function()
	{
		Log::info("hahahah");
		return View::make('illumina.illumina');
	});
I tried it with Route::any
This wouldn't allow either.
publicGenome
Forum Contributor
Posts: 110
Joined: Thu Apr 16, 2015 7:55 am

Re: laravel: cannot reach controller via route

Post by publicGenome »

Update:
After your comment, I changed URL to

Code: Select all

		url:'illumina/illumina_xhr_get_data',
And I can reach my ajax function in the Illumina.

But that leaves me wondering Why I was entering below function at first?

Code: Select all

Route::group(['prefix' => 'illumina', 'namespace' => 'TGen\\Controllers\\illumina','before' => 'auth'], function() {
	
	Log::info(Request::path()); //$uri = Request::path();

Thank you again for your prompt reply Cel :)
Post Reply