AJAX GET request: 404 error

A

Anonymous

Guest
Hi There,

I'm trying to navigate to controller using ajax/Jquery. Get data using ajax, and populate in jqgrid.
My code for Jquery, looks like:

Code:
$(document).ready(function () {
	
	$("#grid_illumina").jqGrid({
		
		url:'illumina_xhr_get_data', //url
		datatype: "json", //get json data
		mtype: "GET", //type
		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'], //column names
        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',	 //pager
   			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
	});
});
Inspect element error:

GET http://localhost/learn_app/public/illumina_xhr_get_data?_search=false&nd=1449091925526&rows=3&page=1&sidx=&sord=asc 404 (Not Found) jquery.js:8540

Application is wrapped in a laravel framework. 4.2 version. I'm able to see the jqGrid, of course it's not populated with any entry.

Similar thing works on my small MVC app. Never saw error as above (concatenated with false, search....). :eek:
I do not get to the laravel routes.php page.
jquery versoin using: 1.9.1

Please help.
 
The url in the ajax request needs to work, the 404 means it can't find it.

http://localhost/learn_app/public/illumina_xhr_get_data

If you are accessing it through the framework, do you need invoke the controller or the url needs to map to the controller.

Get the url working in the browser first and then you can put it in the ajax request.
 
element121 said:
The url in the ajax request needs to work, the 404 means it can't find it.

http://localhost/learn_app/public/illumina_xhr_get_data

If you are accessing it through the framework, do you need invoke the controller or the url needs to map to the controller.

Get the url working in the browser first and then you can put it in the ajax request.

Hi element,
Thanks for your reply. I''m unable to get this URL working, too.

If I put
http://localhost/pims/public/illumina_xhr_get_data

I'll do not reach route.php page, and get a 404 page error
In routes.php

Code:
Route::group(['prefix' => 'illumina', 'before' => 'pims_auth'], function() {
	
	Log::info("In the route");
	//return View::make('illumina.illumina');
	
	$uri = Request::path();
	
	Log::info($uri);
		
});

I get $uri as /

I'd like to reach controller somehow. As of now, no strict rules. Would like to build some skeleton before making huge steps.
Thanks again. :)
 
Hi,
Update: I fixed this.

There was a file named:
unneccessary.htaccess

I renamed it to

.htaccess
It has contents:

<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>

RewriteEngine On
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]

# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>

I found about this from SO

http://stackoverflow.com/questions/24784606/laravel-routes-not-working-apache-configuration-only-allows-for-public-index-ph/24785009#24785009
 
Back
Top