Jquery and Ajax 404 Undefined Error Hi I am developing a module in which i am sending data from javascript to drupal using jquery ajax.

but i am getting 404 error undefined.I am not able to figure out. Pls help

Here is my code

This is tbg.js an external js file

$.ajax({
        url: 'localhost/drupal/my_currenttime/10',
        type: 'GET',
        success: function(data){
            alert(data);
        },
        error: function(jqXHR, textStatus, errorThrown){
            alert(jqXHR.status+textStatus + errorThrown);
        }
    }); 


In my module file i am calling this js file in hook_nodeapi

function modulename_nodeapi(&amp;$node, $op, $a3 = NULL, $a4 = NULL) 
{
  switch($op)
  {
    case 'view':
    drupal_add_js(drupal_get_path('module', 'modulename').'/tbgscript.js', 'module');
    break;
  }  
}


I have created a call back url for the ajax request in modulename_menu() hook

function modulename_menu() 
{
  $items['my_currenttime/%'] = array(
  '#title' =&gt; 'My custom callback',
  'description' =&gt; 'Desc',
  'page callback' =&gt; 'custom_currentTime',
  'page arguments' =&gt; array(1),
  'access arguments' =&gt; array('access content'),
  'type' =&gt; MENU_CALLBACK,
  );

  return $items;
}


and my page call back method is

function custom_currentTime($args)
{
   echo "HELLO".$args;
}


i want to access the value $args in my module file.
I would guess that the URL is wrong in your javascript.

Currently, if your site is on http://localhost, the page requested will be:

http://localhost/localhost/drupal/my_currenttime/10


When I suspect it should be:

http://localhost/drupal/my_currenttime/10


To fix that just add the http:// part to the beginning of the URL variable in your JS code, or make it relative:

url: '/drupal/my_currenttime/10'