使用POST方法的javascript表单

时间:2013-11-29 08:50:12

标签: javascript jquery html post

我想用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();

2 个答案:

答案 0 :(得分:0)

        $.ajax({
                type:'post',
                url:'http://some.com/services/service.php',
                data:{date : dateval ,hour :hourval,minute:minuteval},
                success:function(data){
                   //response..
                    }
                }

            });
        });

答案 1 :(得分: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");