jquery - Mod_rewrite causes AJAX requests using a relative URL to fail -
even though i'm aware there have been posts similar questions before, i'd present issue i've been struggling many hours , can't seem resolve.
on website has urls rewritten mod rewrite module:
www.domain.com/index.php?page=one
becomes
www.domain.com/one/
i'm making ajax request using jquery , relative url >>>>
$.get('views/ajax_page.php', { }, function(data) { alert(data); });
obviously no problem long url in browser's address bar www.domain.com, when variable 'page' not null, script fails find file ajax_page.php , throws ajax error "404 not found".
i know around using absolute url in ajax request, since same-origin policy causes browser throw http error 0 when visitor omits protocol when typing website's address in address bar, not watertight too.
what best way tackle either 1 of aforementioned problems or, better, both? many support.
is folder views @ root of site?
if so, add slash before views:
$.get('/views/ajax_page.php', { }, function(data) { alert(data); });
if not, suggest calling current page ajax request , manage call ajax file in end...
also, make sure htaccess access files before redirecting :
# if directory or file exists, use directly rewritecond %{request_filename} -s [or] rewritecond %{request_filename} -l [or] rewritecond %{request_filename} -d
Comments
Post a Comment