Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/72.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
Jquery Colorbox-如何将数据属性设置为使用POST而不是GET_Jquery_Ajax_Jquery Plugins_Colorbox - Fatal编程技术网

Jquery Colorbox-如何将数据属性设置为使用POST而不是GET

Jquery Colorbox-如何将数据属性设置为使用POST而不是GET,jquery,ajax,jquery-plugins,colorbox,Jquery,Ajax,Jquery Plugins,Colorbox,我使用的是colorbox插件,根据文档,data属性允许通过ajax请求提交GET或POST值。我可以通过GET提交我的数据,但我不知道如何切换到POST。我正在使用serialize以名称/值对的形式设置表单数据。我的代码如下: 有没有办法将此设置为POST var data = $('form').serialize(); console.log(data); // Preview newsletter - bind colorbox t

我使用的是colorbox插件,根据文档,
data
属性允许通过ajax请求提交GET或POST值。我可以通过GET提交我的数据,但我不知道如何切换到POST。我正在使用serialize以名称/值对的形式设置表单数据。我的代码如下:

有没有办法将此设置为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;
        });

data属性的作用与jQuery的.load()数据参数完全相同,因为ColorBox使用.load()进行ajax处理。

使用

 $('form').serializeArray();

@Vivek Goel-啊,我明白了,好的,我目前正在以键/值对的形式传递数据,比如intro=&proj=7,这如何转换为对象?from.serialize提供字符串。或者将其转换为对象。您能提供一个示例吗?