繁体   English   中英

使用Dojo提交表单并检索结果

[英]Submit form and retrieve result using Dojo

谁能提供一个简单的示例,说明如何使用dojo来对表单进行修饰并从php脚本中检索结果?

喜欢

<form action="login.php" method="post">
  <input type="text" name="user">
  <input type="password" name="password">
  <input type="button" value="login">
</form>

+

<?PHP
if($_POST["user"] == "test" && $_POST["password"] == "test") {
  echo "youre logged in successfully [REDIRECT HERE]";
}
else {
  echo "you failed epic";
}
?>

+

dojo.xhrpost还是什么?

xhrPOST-例如

// Local var representing if the form has been sent at all
var hasBeenSent = false;
// Local var representing node to be updated
var messageNode = dojo.byId("messageNode");
// Using dojo.xhrPost, as the amount of data sent could be large
dojo.xhrPost({
    // The URL of the request
    url: "submission.php",
    // No content property -- just send the entire form
    form: dojo.byId("contactForm"),
    // The success handler
    load: function(response) {
        messageNode.innerHTML = "Thank you for contacting us!";
    },
    // The error handler
    error: function() {
        messageNode.innerHTML = "Your message could not be sent, please try again."
    },
    // The complete handler
    handle: function() {
        hasBeenSent = true;
    }
});

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM