彩盒 - 如何设置data属性中使用GET的POST而不是 [英] Colorbox - how to set data property to use POST instead of GET

查看:163
本文介绍了彩盒 - 如何设置data属性中使用GET的POST而不是的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的颜色框插件,并根据文档中,数据属性可以通过一个Ajax请求提交GET或POST值。我可以通过GET没有问题提交我的数据,但无法弄清楚如何切换到POST。我使用序列设置表单数据的名称/值对。我有以下的code:

有没有办法将其设置为POST?

  VAR数据= $('表')序列化()。

            的console.log(数据);

            // preVIEW通讯 - 颜色框绑定到事件
            $('A#preVIEW')。颜色框({
                宽度:'670px',
                HREF:$(本).attr(HREF),
                数据:数据
            });

            返回false;
        });
 

解决方案

使用

  $('表')serializeArray()。
 

I'm using the colorbox plugin and according to the docs, the data property allows submitting GET or POST values through an ajax request. I can submit my data via GET no problem, but can't figure out how to switch to POST. I'm using serialize to set the form data in name/value pairs. I have the code below:

Is there a way to set this to POST?

var data = $('form').serialize();

            console.log(data);

            // Preview newsletter - bind colorbox to event
            $('a#preview').colorbox({
                width: '670px',
                href: $(this).attr('href'),
                data: data
            });

            return false;
        });

解决方案

Use

 $('form').serializeArray();

这篇关于彩盒 - 如何设置data属性中使用GET的POST而不是的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆