使用POST方法的JavaScript形式

问题描述 投票:-4回答:2

我想用JavaScript发布,我有3个数据。

如何使用这种形式的javascript发布3个值?

                        dateval = $('#tarih input.datepicker').val();
                        hourval = $('#scheduleHour').val();
                        minuteval = $('#scheduleMinute').val();

                        var form = document.createElement("form");
                        form.setAttribute("method", "post");
                        form.setAttribute("action", "/app/" + @appId + "/volumes/" + obj.data("rowid") + "/scheduledPublish");
                        var hiddenField = document.createElement("input");
                        hiddenField.setAttribute("type", "hidden");
                        hiddenField.setAttribute("name", "dateval");
                        hiddenField.setAttribute("value", result);
                        form.appendChild(hiddenField);
                        document.body.appendChild(form);
                        form.submit();
javascript jquery html post
2个回答
0
投票

像这样发帖;

    var form = document.createElement("form");
    form.setAttribute("method", "post");
    form.setAttribute("action", "/app/" + @appId + "/volumes/" + obj.data("rowid") + "/scheduledPublish");

    var hiddenField = document.createElement("input");
    hiddenField.setAttribute("type", "hidden");
    hiddenField.setAttribute("name", "dateval");
    hiddenField.setAttribute("value", dateval);
    form.appendChild(hiddenField)

并像这样从java获取;

    form.data().get("name value");

0
投票
$.ajax({
    type: 'post',
    url: 'http://some.com/services/service.php',
    data: { date: dateval, hour: hourval, minute: minuteval },
    success: function (data) {
        //response..
    }
});
© www.soinside.com 2019 - 2024. All rights reserved.