1

MVC 3 の使用

3 つのセクションがあるアンケートがあります。アンケートのあるページに「次へ」「前へ」「保存」ボタンはありますか?これらのボタンのいずれかをクリックすると、「Question/SectionComplete」という Actioncontroller への ajax 呼び出しが必要です。true が返された場合、完全なアイコンを表示する css でメニュー div を更新します。サンプル コードを使い始めるのを手伝ってくれる人はいますか?

4

2 に答える 2

0

.ajax メソッドの成功関数を使用します - ドキュメントはこちら - http://api.jquery.com/jQuery.ajax/

$.ajax({
  url: '/Question/SectionComplete',
  success: function(data) {
      // add code here
      // test for your response
      // then use jquery selector to get element to be updated
      // and use .html() to set element's new value
  }
});
于 2013-01-10T06:12:57.877 に答える
0
function onButtonClick(){
    var data = { myvar: 1 }; // your data to pass to action
    $.getJSON('Question/SectionComplete', data, function(result){
        if(result)
            $('#mymenudiv').css('background-image', 'yourImage'); //your styles here
    })
}

コントローラーで:

public ActionResult SectionComplete(int myvar)
{
    // check condition
    return Json(true, JsonRequestBehaviour.AllowGet); // you can return complex object instead
}
于 2013-01-10T06:13:29.230 に答える