AJAX GET request: 404 error

Javascript coding ..

Moderators: egami, macek, gesf

Post Reply
publicGenome
New php-forum User
New php-forum User
Posts: 17
Joined: Fri Oct 30, 2015 4:13 am

Wed Dec 02, 2015 1:49 pm

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: Select all


$(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/illum ... =&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....). :o
I do not get to the laravel routes.php page.
jquery versoin using: 1.9.1

Please help.

element121
php-forum Fan User
php-forum Fan User
Posts: 606
Joined: Sat Jun 06, 2015 11:46 am
Contact:

Wed Dec 02, 2015 2:24 pm

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.

publicGenome
New php-forum User
New php-forum User
Posts: 17
Joined: Fri Oct 30, 2015 4:13 am

Wed Dec 02, 2015 2:35 pm

element121 wrote: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
I'll do not reach route.php page, and get a 404 page error
In routes.php

Code: Select all

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. :)

publicGenome
New php-forum User
New php-forum User
Posts: 17
Joined: Fri Oct 30, 2015 4:13 am

Wed Dec 02, 2015 2:42 pm

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/2478 ... 9#24785009

Post Reply