2012-08-06 86 views
-1
$.ajax({ 
     url: 'index.php?route=account/edit', 
     type: 'post', 
     data: $('#account_edit input[type=\'text\'], #account_edit input[type=\'password\'],**#account_edit input[type=\'file\']**,#account_edit input[type=\'radio\']:checked'), 
     dataType: 'json', 
     beforeSend: function() { 
      $('#button-update').attr('disabled', true); 
      $('#button-update').after('<span class="wait">&nbsp;<img src="catalog/view/theme/default/image/loading.gif" alt="" /></span>'); 
     }, 
     complete: function() { 
      $('#button-update').attr('disabled', false); 
      $('.wait').remove(); 
     },   
     success: function(json) { 
      $('.warning').remove(); 
      $('.error').remove(); 
      //alert(json['error']['firstname']); 

      if (json['redirect']) { 
       //location = json['redirect']; 
      } 

} 
+0

請添加一些問題描述。 – 2012-08-06 12:24:42

+0

http://stackoverflow.com/questions/10492617/how-can-i-upload-a-file-using-jquerys-ajax-function-with-json-and-php?rq=1 – 2012-08-06 12:27:48

回答

0

$ .ajax()不支持文件上傳。更好的是你應該嘗試一些插件,如ajaxForm來上傳文件。