2010-08-15 62 views
0

我想這個代碼Protoytpe轉換爲JQuery的:原型jQuery的

Event.observe(window, 'load', init, false); 

function init(){ 
Event.observe('signup','submit',storeAddress); 
} 

// AJAX call sending sign up info to store-address.php 
function storeAddress(event) { 
// Update user interface 
$$('response').innerHTML = 'Adding email address...'; 
// Prepare query string and send AJAX request 
var pars = 'ajax=true&email=' + escape($F('email')); 
var myAjax = new Ajax.Updater('response', '/mailchimp/store-address.php', {method: 'get', parameters: pars}); 
Event.stop(event); // Stop form from submitting when JS is enabled 
} 

任何幫助表示讚賞!

回答

3
$(function() { 
    $('#signup').submit(function(e) { 
     var el = this; 
     e.preventDefault() 
     $('response').html('Adding email address'); 
     $.ajax({ 
      url:'/mailchimp/store-address.php', 
      data: 'ajax=true&' + $(el).serialize(), 
      success:function(){} 
     }); 
    }); 
}); 

這應該讓你開始,你可以填寫缺少的部分或修改它。請記住引用API