2

次のコードを書いて、modeldata と currenttime をコントローラー action.what に送信します。これを渡す正しい方法は何ですか。

$(document).ready(function () {

    timeClock = setInterval("TimeTick()", 10);
    SwipeIn(); SwipeOut();

    $('#btnswipeIn').click(function () {

        clearTimeout(swipeinId);

        var ptime = $("#swipeIn").text();

        alert(ptime);

        var url = "EmployeeDashBoard/Index/";

        $.post(url, { model: $("#dashboard").serialize(), time: ptime }, function (result) { $('#time').html(resul.time) });


    });

});
4

2 に答える 2

2

modeldata と currenttime をコントローラー アクションに送信する正しい方法は次のとおりです。

$(function () { 

    $("#proedtbtn").click(function () { 
window.location.href = "/Controller/ActionName/" + parameter1 + "?parameter2=" + parameter2.val + "&parameter3=" + parameter3.val;
    });
});

ここで、 proedbtnはビューで使用される送信ボタンです。上記のパラメーターの代わりに、時間などのコントローラー アクションに送信する任意の値を配置できます。

于 2013-06-03T12:10:38.583 に答える
0

serializeArrayを試す

$(document).ready(function () {

  timeClock = setInterval("TimeTick()", 10);
  SwipeIn(); SwipeOut();

  $('#btnswipeIn').click(function () {

    clearTimeout(swipeinId);

    var ptime = $("#swipeIn").text();

    alert(ptime);

    var url = "EmployeeDashBoard/Index/";

    var data = $("#dashboard").serializeArray();
    data.push({name: 'time', value: ptime});

    $.post(url, data, function (result) { $('#time').html(result.time); });
  });
});
于 2013-06-03T12:12:37.687 に答える