Ajax Autocomplete Textfield drupal

function module_name_form() { $form = array(); $form[‘city’] = array( ‘#title’ => t(‘City’), ‘#type’ => ‘textfield’, ‘#autocomplete_path’ => ‘example/autocomplete’, ); $form[‘submit’] = array( ‘#type’ => ‘submit’, ‘#value’ => ‘Save’, ); return $form; } function module_name_menu() { $items[‘example/autocomplete’] = array( ‘page callback’ => ‘_module_name_autocomplete’, ‘access arguments’ => array(‘access example autocomplete’), ‘type’ => MENU_CALLBACK ); return $items; }… Continue reading Ajax Autocomplete Textfield drupal

Using AJAX – Pros and Cons

AJAX (Asynchronous JavaScript and XML) has evolved as a powerful, user-friendly and developer-friendly platform for building web based interactive applications. When used with sound technical understanding, it can take the user experience to a whole new level. AJAX has been in a dormant existence for over a decade. Credit goes to Google to bring it… Continue reading Using AJAX – Pros and Cons

Creating jQuery AJAX requests to a PHP function Instead of PHP file

Use $.ajax to call a server context (or URL, or whatever) to invoke a particular ‘action’. What you want is something like: $.ajax({ url: ‘/my/site’,          data: {action: ‘test’},          type: ‘post’,          success: function(output) {              alert(output);      … Continue reading Creating jQuery AJAX requests to a PHP function Instead of PHP file

Return data after ajax call success jQuery

The only way to return the data from the function would be to make a synchronous call instead of an asynchronous call, but that would freeze up the browser while it’s waiting for the response. You can pass in a callback function that handles the result: function testAjax(handleData) { $.ajax({ url:”getvalue.php”, success:function(data) { handleData(data); }… Continue reading Return data after ajax call success jQuery

Submit two forms with one button

A form submission causes the page to navigate away to the action of the form. So, you cannot submit both forms in the traditional way. If you try to do so with JavaScript by calling form.submit() on each form in succession, each request will be aborted except for the last submission. So, you need to submit the first form… Continue reading Submit two forms with one button