Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/perl/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在magento的ajax页面上获取文件数据?_Magento - Fatal编程技术网

如何在magento的ajax页面上获取文件数据?

如何在magento的ajax页面上获取文件数据?,magento,Magento,我在magento中制作了一个自定义模块。我在其中使用ajax(prototype.js)。我可以在ajax页面上找到post变量。但是我在ajax页面上找不到文件数组。 我正在为此使用以下代码。请让我知道我错在哪里 //Ajax code on phtml page new Ajax.Request( reloadurl, { method: 'post', parameters: $('use-credit-Form').serialize()

我在magento中制作了一个自定义模块。我在其中使用ajax(prototype.js)。我可以在ajax页面上找到post变量。但是我在ajax页面上找不到文件数组。 我正在为此使用以下代码。请让我知道我错在哪里

//Ajax code on phtml page
new Ajax.Request(
    reloadurl,
    {
        method: 'post',
        parameters: $('use-credit-Form').serialize(),
        onComplete: function(data)
        {
             alert(data.responseText);
        }
    });
//Php code on ajaxpage
public function ajaxAction()
{
    $fileData   =   $_FILES;
    echo '<pre>';
    print_r($fileData);die;
}
//phtml页面上的Ajax代码
新的Ajax.Request(
重新加载URL,
{
方法:“post”,
参数:$('use-credit-Form')。序列化(),
onComplete:函数(数据)
{
警报(data.responseText);
}
});
//ajaxpage上的Php代码
公共功能ajaxAction()
{
$fileData=$\u文件;
回声';
打印($fileData);模具;
}
它总是空白打印。但是当我添加这一行时 “VarieForm.prototype.submit.bind(usecreditForm)();” 我可以得到文件数组的值。但现在后退,页面开始刷新

请给我一些建议。

试试这个:


信用证:

你的HTML是什么样子的?没有AJAX它可以工作吗?是的,没有AJAX它工作得很好。我尝试一下,但问题仍然是一样的。仍然没有文件数据。当我打印$\文件时。它总是空白打印。
Event.observe('use-credit-Form', 'submit', function (event) {
    $('use-credit-Form').request({
        onFailure: function () {
            alert('fail.');
        },
        onSuccess: function (data) {
            alert(data.responseText);
        }
    });
    Event.stop(event); // stop the form from submitting
});