我有一个横幅,上面有一个联系表。如果某些字段为空并且用户尝试提交它,则横幅将返回响应。但由于某种原因,响应文本中断或缺少字母。
/*ActionScript 3.0 */
name_txt.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler);
function fl_MouseClickHandler(event:MouseEvent):void {
trace("Mouse clicked");
stop();
}
// custom function we create to populate the comboBox list
function addShopsToList ():void {
shopList.addItem( { label: "Esindus1" } );
shopList.addItem( { label: "Esindus2" } );
shopList.addItem( { label: "Esindus3" } );
shopList.addItem( { label: "Esindus4" } );
}
// Run function above now
addShopsToList ();
// build variable name for the URL Variables loader
var variables:URLVariables = new URLVariables;
// Build the varSend variable
var varSend:URLRequest = new URLRequest("form_parse.php");
varSend.method = URLRequestMethod.POST;
varSend.data = variables;
// Build the varLoader variable
var varLoader:URLLoader = new URLLoader;
varLoader.dataFormat = URLLoaderDataFormat.VARIABLES;
varLoader.addEventListener(Event.COMPLETE, completeHandler);
// handler for the PHP script completion and return of status
function completeHandler(event:Event):void {
// remove processing clip
name_txt.text = "";
email_txt.text = "";
phone_txt.text = "";
// Load the response from php here
status_txt.text = event.target.data.return_msg;
}
// Add event listener for submit button click
submit_btn.addEventListener(MouseEvent.CLICK, ValidateAndSend);
// function ValidateAndSend
function ValidateAndSend (event:MouseEvent):void {
// validate fields
if(!name_txt.length) {
status_txt.text = "Please enter your name";
} else if (!email_txt.length) {
status_txt.text = "Please enter your email";
} else if (!phone_txt.length) {
status_txt.text = "Please enter your phone number";
} else {
// All is good, send the data now to PHP
// ready the variables in our form for sending
variables.userName = name_txt.text;
variables.userEmail = email_txt.text;
variables.userPhone = phone_txt.text;
variables.userShop = shopList.value;
// Send the data to PHP now
varLoader.load(varSend);
} // close else condition for error handling
} // close validate and send function
PHP:成功提交后:
$my_msg = "Täname $senderName, päringu eest."; // Thanking the user for successful completion
// Print the data back to flash who is patiently waiting for it in the onCompleteHandler
print "return_msg=$my_msg";
有任何想法吗?