why cakephp producing urls
<server>/reporting/onlinebanking/index/page:1
instead of
<server>/reporting/onlinebanking/index?page=1
there alot of trouble using relative paths out of javascript example.
and there option change it?
pagination parameters
by default, parameters in cakephp named parameters (url fragments /foo:bar/
). applies, default, pagination arguments.
to use arguments pagination params - can setting appropriate config:
public $paginate = array( 'paramtype' => 'querystring' );
this generate urls of form:
/the/url?page=1&limit=10
instead of:
/the/url/page:1/limit:10
specifying urls string
extremely fragile
previously mentioned using urls get_backend_requests
in javascript.
you still find problems if using arguments of pagination. that's because "same" url, result can different:
/the/url => /the/get_backend_requests /the/url/ => /the/url/get_backend_requests
instead - specify urls in javascript absolute urls:
$.ajax({ type: 'post', url: "/xyz/get_backend_requests", ...
if you're app (or always) installed in subfolder, can account simple function:
e.g. in html/layout put:
<html> ... <script> function url(url) { return <?php $base = rtrim(router::url('/'), '/'); if ($base) { echo "'$base' + "; } ?>url; } </script>
which output:
<html> ... <script> function url(url) { return '/subfolder' + url; } </script> $.ajax({ type: 'post', url: url("/xyz/get_backend_requests"), // becomes string "/subfolder/xyz/get_backend_requests" ...
Comments
Post a Comment