Laravel 4,jQuery的阿贾克斯,未收到邮寄的输入 [英] Laravel 4, jQuery .ajax, No post input received
问题描述
我一定是失去了一些东西,没想到这会是一个问题。
I must be missing something, didn't think this would have been a issue.
我有没有连接laravel形式的登录表单,虽然其在同一个域,并在登录一个POST路由laravel。
I have a login form that has no connection to laravel form, although its on the same domain, and a POST route with laravel at "login".
我可以改变它来获得,一切工作,但我想用POST。
I can change it to GET and everything works, but I would like to use POST.
/online/index.html
$("#login").click(function(e){
console.log( $("#loginForm").serialize() );
var request = $.ajax({
url: "../login/",
type: "POST",
data: { test : "someuser" },
dataType: "json"
});
request.done(function( data ) {
console.log("Complete");
console.log(data);
});
request.fail(function( jqXHR, textStatus ) {
console.log("Failed");
console.log(textStatus);
});
});
路线::职位('登录',阵列('为'=>'登录','使用'=>'AuthController @ doLogin'));
(这是低于/在线/)
Route::post('login', array('as' => 'login', 'uses' => 'AuthController@doLogin'));
( which is below /online/ )
class AuthController extends Controller {
public function doLogin(){
$username = Input::get('username');
$password = Input::get('password');
return Response::json(Input::all());
}
}
在JavaScript控制台,当你preSS登录,它显示...
In the javascript console, when you press login, it shows...
Complete
[]
当它应该说这样的事情...
When it should say something like this...
Complete
[ test => "someuser" ]
使用Laravel 4,jQuery的1.8.3。任何想法将是巨大的...谢谢!
Using Laravel 4, jQuery 1.8.3. Any ideas would be great... Thanks!
推荐答案
我只是删除了Ajax请求的URL的斜线和一切工作按计划进行。
I just removed the trailing slash in the Ajax request URL and everything worked as planned.
这篇关于Laravel 4,jQuery的阿贾克斯,未收到邮寄的输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!