I don't know if this is strictly a jquery issue or drupal's. I have an ajax call:
$.ajax({ type: 'get', url: URL, data: refined_url, dataType: 'html', success: function (data, textStatus, XMLHttpRequest) { document.getElementById('search_result_page').innerHTML = data; }, error:function (xhr, ajaxOptions, thrownError){ alert(xhr.status); alert(xhr.statusText); alert(xhr.responseText); } }); // end ajax method
The problem seems to be that the URL value used by ajax is a concatenation of the current directory and the URL value I supply. Say the URL I supply is 'sites/all/modules/mymodule/wrapper.php' (this is a concatenation of drupal_get_path('module', 'mymodule') and the wrapper.php file). Ajax wants to make it 'node/sites/all/modules/mymodule/wrapper.php'. This of course results in a 404 error.
I have checked the value of URL with alert(URL) immediately before the ajax call and the variable contains the correct value. Online documentation mentions that ajax uses the current directory by default. I want it to use the string I provide.
Add a / to the beginning of the URL and you'll be fine.
Jamie Holly http://www.intoxination.net http://www.hollyit.net
On 6/7/2010 1:22 PM, Scott wrote:
I don't know if this is strictly a jquery issue or drupal's. I have an ajax call:
$.ajax({ type: 'get', url: URL, data: refined_url, dataType: 'html', success: function (data, textStatus, XMLHttpRequest) { document.getElementById('search_result_page').innerHTML = data; }, error:function (xhr, ajaxOptions, thrownError){ alert(xhr.status); alert(xhr.statusText); alert(xhr.responseText); } }); // end ajax method
The problem seems to be that the URL value used by ajax is a concatenation of the current directory and the URL value I supply. Say the URL I supply is 'sites/all/modules/mymodule/wrapper.php' (this is a concatenation of drupal_get_path('module', 'mymodule') and the wrapper.php file). Ajax wants to make it 'node/sites/all/modules/mymodule/wrapper.php'. This of course results in a 404 error.
I have checked the value of URL with alert(URL) immediately before the ajax call and the variable contains the correct value. Online documentation mentions that ajax uses the current directory by default. I want it to use the string I provide.
Many thanks, that did the trick...
On Mon, 2010-06-07 at 15:22 -0400, Jamie Holly wrote:
Add a / to the beginning of the URL and you'll be fine.
Jamie Holly http://www.intoxination.net http://www.hollyit.net