我正在使用 mootools 框架来构建我的网站,使用 php 进行编码。现在我想通过 mootools 提交表单,其中包含带有文件上传器的基本 html 标签。那么,如何使用 mootools 请求将此文件发送到“.php”页面?
问问题
534 次
2 回答
0
作为@lorenzo-s 答案的替代方案,如果您要返回 JSON 编码数据,您可能需要考虑使用Mootools Request,或者甚至是Request.JSON 。
Javascript
var myRequest = new Request({ // This defines the AJAX call's parameters (url, callback function, etc)
url: '/url/to/script.php',
onSuccess: function(returnText) {
console.log(returnText);
}
});
myRequest.post({ foo: 'bar' }); // This makes the actual call, sending an object with one property: `foo`.
于 2012-05-14T13:21:06.733 回答
0
如果文件上传器是标准<input type="file">
并且包含在 a 之间<form enctype="multipart/form-data">
,您可以通过 Javascript 发送表单。
<form id="myForm" method="post" enctype="multipart/form-data">
<input type="file" name="myFile">
</form>
$('myForm').submit();
于 2012-05-14T12:35:23.167 回答