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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to use GET request? #30
Comments
I seem to get what the problem is. 810 line of code contains declaring of "method" varible which came from "phery" arguments of generated link, but it's never used. I had to manually change the source by pasting it into 1006 line, where "type" parameter of generic ajax function is declared. It was hardcoded as just "POST". |
Please consider this in the future releases. |
hey @firestorm23 it seems that it's left out of docs indeed. to generate a request with a METHOD_OVERRIDE using link_to, needs to set the Phery::link_to('Click me', 'remote', array('method' => 'GET')); Although the request will still be sent as a POST to the server, there will be an added HTTP header with |
Oh, I see. Thank you for pointing out about header. Looks like this feature makes it more tricky to use with Symfony Framework, because it ignores this header if the app is behind HTTP caching. |
Still, consider this. Something tells me that this header is not popular, so your solution could be given up by those who had problem with this issue. By the way it is great, integreated it with Symfony Request/Response, and it works great without duplicating code in Controller and Views. |
I don't know Symfony, but doesn't this solve the problem? http://api.symfony.com/2.7/Symfony/Component/HttpFoundation/Request.html#method_enableHttpMethodParameterOverride The issue with using non-POST is that you can't mix file uploads with data, and phery does this by default, either by sending the entire form or a file input along with arbitrary data |
Yes, this method should work according to what i read. I'll try it. |
Returning to this issue. I actually found that no sign of sending X-HTTP-Method-Override in the source code nor catching it in the browser or server was found. |
In the current phery.js '_headers' object that is sent, does not contain instructions to contain X-HTTP-Method-Override header. It's in 801-804 lines. |
you're right, the info actually comes in the second parameter on the callback: Phery::instance()->set([
'postAsGet' => function($data, $pheryData) {
$pheryData['method'] === 'GET'
}
])->process(); <div>
<?php echo Phery::link_to('click me', 'postAsGet', ['method' => 'GET']); ?>
</div> I should change it to use HTTP override, it's the proper way (You see, I thought of this, but didn't make the change yet) |
Suddenly I realised that docs have no clue how to declare a GET method when generating link_to().
Tried to reverse searching the source .js, but it didnt help. I see that it contains processing of method parameter but I somehow dont understand how to declare it.
The text was updated successfully, but these errors were encountered: