通过AJAX数据传递多个数据值

时间:2017-07-29 15:37:40

标签: jquery ajax

我通过正常的AJAX调用从表单传递数据。我现在需要做的是通过elatelng

传递两个额外的变量

通过AJAX数据包含filter.serialize()elat elng值的最佳方法是什么?

    var elat = place.geometry.location.lat();
    var elng = place.geometry.location.lng();

    var filter = $('#filter');

    $.ajax({
        url: filter.attr('action'),
        data:filter.serialize(), //Pass [elat] and [elng] through here too.
        type: 'POST',
        dataType: 'json',
        success: function(response) {
        }
    });

1 个答案:

答案 0 :(得分:2)

您可以手动连接到data:filter.serialize() + '&elat=' + elat + '&elng=' + elng,

生成的字符串
filter.append( $('<input>',{type:'hidden', name:'elat'}).val(elat));
filter.append( $('<input>',{type:'hidden', name:'elng'}).val(elng));

或者在序列化之前向表单添加隐藏的输入。

Sub CreatePres()

Dim ppApp As PowerPoint.Application
Dim ppPres As PowerPoint.Presentation
Dim ppSlide As PowerPoint.Slide
Dim ppTextbox As PowerPoint.Shape

Set ppApp = New PowerPoint.Application
ppApp.Visible = True
ppApp.Activate

Set ppPres = ppApp.Presentations.Add
slidesCount = ppPres.Slides.Count
Set ppSlide = ppPres.Slides.Add(slidesCount + 1, ppLayoutTitle)
ppSlide.Shapes(1).TextFrame.TextRange.Text = "Hello world"
ppSlide.Shapes(2).TextFrame.TextRange.Text = Date
slidesCount = slidesCount + 1

Call slide2(slidesCount)

End Sub
Sub slide2(i As Integer)
Set ppSlide = ppPres.Slides.Add(i + 1, ppLayoutTitle)
ppSlide.Select
ppSlide.Shapes(1).TextFrame.TextRange.Text = "Hello world"
ppSlide.Shapes(2).TextFrame.TextRange.Text = Date

End Sub
相关问题