weixin_33739541 2016-09-26 04:39 采纳率: 0%
浏览 23

Ajax表单提交-typo3

Hi I have a extbase typo3 extension.It contain a model window with a form.On submit an ajax call updates the underlying table via updateAction.My problem is that how to get the form argument via getArgument() method in controller.My code is given below

My form is

   <form id="updatewindow" method="POST"  name="iframe">
   <p><label for="fields">' + $(title).html() + ':</label>
   <input type="text" value="' + cell_data + '" name="tx_suserform_userform[newUser][name]"></p>
   </form>

Ajax Call

url_update = '<f:uri.action  action="updateFileds" absolute="1" noCacheHash="1"/>';
jQuery.ajax({
        url: url_update,
        type: "POST",
        data: params,
        success: function (data) {
            if (data == 'true') {
                location.reload();
            } else {
            }
        }
    });

In my controller I wrote

 $post_val =  $this->request->getArgument('name');

but it returns error and

 $this->request->getArguments()

only return controller name and action

  • 写回答

2条回答 默认 最新

  • weixin_33709590 2016-09-26 05:00
    关注

    You can get the form data using JavaScripts FormData object:

    url_update = '<f:uri.action  action="updateFileds" absolute="1" noCacheHash="1"/>';
    var params = new FormData(jQuery('#updatewindow').get(0));
    jQuery.ajax({
        url: url_update,
        type: "POST",
        data: params,
        success: function (data) {
            if (data == 'true') {
                location.reload();
            } else {
            }
        }
    });
    

    You should probably render your form using fluid, otherwise some stuff extbase relies on will be missing from the form (check the hidden div in any fluid generated form).

    To get the URL to POST the data to, I'd recommend using the extension typoscript_rendering - it's made for this exact purpose. It generates an URL which won't return the whole HTML page, but only the result from the template of the called action. You need to have cHashes enabled to use it.

    评论

报告相同问题?

悬赏问题

  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 AT89C51控制8位八段数码管显示时钟。
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题