2012-07-10 72 views
0

我想驗證窗體使用JavaScript。一旦下面的代碼執行,我想從外部腳本獲取PHP運行沒有頁面加載與成功消息誰能幫助後?javascript ajax,表單提交然後頁面加載

下面的腳本工作正常,並從一個單獨的函數拉notEmpty。我需要的腳本然後: 1.如果沒有產生錯誤,然後拉動php並從列出的每個值傳輸數據。 2.顯示成功消息

var year = document.getElementById('year'); 
var period = document.getElementById('period'); 
var live = document.getElementById('live'); 
var start = document.getElementById('start'); 
var todate = document.getElementById('todate'); 
var sdeadline = document.getElementById('sdeadline'); 
var cdeadline = document.getElementById('cdeadline'); 
var circ = document.getElementById('circ'); 
var line = document.getElementById('line'); 

// Check each input in the order that it appears in the form! 
if(notEmpty(year, "Please fill in Year")){ 
if(notEmpty(period, "Please fill in Period")){ 
if(notEmpty(live, "Please fill in live Date")){ 
if(notEmpty(start, "Please fill in Start Date")){ 
if(notEmpty(todate, "Please fill in End Date")){ 
if(notEmpty(sdeadline, "Please fill in Supplier Deadline")){ 
if(notEmpty(cdeadline, "Please fill in Commerical Deadline")){ 
if(notEmpty(circ, "Please fill in Circulars Due")){ 
if(notEmpty(line, "Please fill in Line Listing Downloads")){ 

}}}}}}}}} 


return false; 
+3

這聽起來像你只需要一個入門教程阿賈克斯。 – Quentin 2012-07-10 11:33:32

+0

即時通訊不是很好,所以任何幫助或指引我在正確的方向將是驚人的 – phpdev1982 2012-07-10 11:38:44

+0

https://developer.mozilla.org/en/AJAX – Quentin 2012-07-10 11:40:18

回答

0

的IDEEA是創建數據的字符串要傳遞給PHP腳本:

var datasend = 'year='+year+'&period='+period+'&live='+live+ ...; 

然後,如果沒有錯誤,調用一個Ajax功能通過將字符串發送到服務器。

看到一個教程的:AJAX with POST and PHP

相關問題