Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork69
Add postAjax() to Html Builder#45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
yajra commentedNov 28, 2017
Nice idea on adding the token header. The PR looks good but will some actual test within the week. Thanks! I think we should also note that there is an implication here on the routes. If you are using resource controller, then the request would go to the store method. |
ElfSundae commentedNov 28, 2017
@yajra Yeah, you are right, thanks for reminding. I did not notice resource controllers as I use my custom resource routes&controller instead of Laravel built-in Adding a POST route to index may be a workaround? Route::post('users','UserController@index');Route::resource('users','UserController', ['except' =>'store']); I know it is not an elegant solution, I am not familiar with Laravel resource controller... |
ElfSundae commentedNov 28, 2017
Another solution: set - if (app()->bound('session') && $token = app('session')->token()) {- $attributes = Arr::add($attributes, 'headers.X-CSRF-TOKEN', $token);- }+ Arr::set($attributes, 'headers.X-HTTP-Method-Override', 'GET'); But we should note that using |
ElfSundae commentedNov 28, 2017
Another solution: Remove parameters for $builder->ajax(...)->postAjax(); Or maybe better to do this by changing publicfunction ajax($attributes ='',$post =false) I will submit a new PR for this. |
yajra commentedDec 15, 2017
Released on v3.3.0 🎊 🚀 |
As@herzcthu said on#13 (comment) ,
minifiedAjaxdoes not help for a "very big" table.I think POST ajax is common as well as GET, so I'd like to add a new method
postAjax()to theHtml\Builder, andpostAjax()has the same API asajax().equals:
typeandmethod, any other options will be merged into the finalajaxparameter, users are free to set any options forajax.urlis unnecessary, so I did not fill the defaulturlvalue. If there is a reason to provide a default url, I will add it.X-CSRF-TOKENheader is a safe way to handle CSRF protection. It does not touch/careajax.data,ajax.beforeSend,jQuery.ajaxPrefilter,jQuery.ajaxSetup, even existingajax.headers.X-CSRF-TOKEN.