Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
89
rated 0 times [  90] [ 1]  / answers: 1 / hits: 8545  / 9 Years ago, sat, april 18, 2015, 12:00:00

I just start using Laravel 5 and i'm facing a problem to send Ajax json data from the view to controller ..



This is my routes.php :



Route::post('ticket','TicketController@store');

Route::get('ticket', 'TicketController@index');


and this is the controller :



public function store()
{

return Response::json(Input::get('ticketname'));

}


and Finally for the View i have this simple example to pass just one input :



<script>

$(document).ready(function() {

$('#go').on(click,function(){


var ticketname= ($('.tick_name').val());

$.ajax({
url: 'ticket',
type: 'POST',
data: {ticketname:$('.tick_name').val()},
dataType: 'json',
success: function(info){
console.log(info);
}

});


});

});




**IM ALWAYS GETTING THIS ERROR : localhost:8000/ticket



500 Internal Server Error on jquery.js line 4 ..**



CAN anyone help please !


More From » php

 Answers
10

Response is an alias in the global namespace. Since you're current namespace is AppHttpControllers you have to import the class:



use Response;


Or prepend a backslash:



return Response::json(Input::get('ticketname'));

[#37823] Friday, April 17, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
laytonlamontm

Total Points: 745
Total Questions: 130
Total Answers: 130

Location: Cambodia
Member since Thu, Oct 7, 2021
3 Years ago
;