Top > SAStrutsあれこれ > リクエストパラメータ付きHTMLをAjaxで取得

Everything is expanded.Everything is shortened.
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
<%@page pageEncoding="UTF-8"%>
<html>
<head>
<title>Tutorial: Ajax</title>
<link rel="stylesheet" type="text/css" href="${f:url('/css/sa.css')}" />
<script src="${f:url('/js/jquery.js')}"></script>
</head>
<body>
 
<h1>Tutorial: Ajax</h1>
 
<input type="text" id="greeting" value=""/>
<input type="button" value="hello" onclick="$('#message').load('hello',{'greeting': $('#greeting').val()});"/>
 
<span id="message"></span><br />
 
</body>
</html>   
Everything is expanded.Everything is shortened.
  1
  2
  3
  4
  5
  6
  7
  8
 
 
 
 
 
 
 
 
<%@page pageEncoding="UTF-8"%>
<h2>Received Results</h2>
<table border=1>
  <tr>
    <th>Greeting</th>
    <td>${greeting}</td>
  </tr>
</table>

Everything is expanded.Everything is shortened.
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 
 
 
 
-
|
|
|
|
-
|
!
|
|
-
|
|
|
!
!
package tutorial.action;
 
import org.seasar.struts.annotation.Execute;
 
public class AjaxAction {
 
    public String greeting;
    
    @Execute(validator = false)
    public String index() {
        return "index.jsp";
    }
 
    @Execute(validator = false)
    public String hello() {
        // ResponseUtil.write("こんにちは");
        // return null;
        return "greeting.jsp";
    }
}

Everything is expanded.Everything is shortened.
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
<%@page pageEncoding="UTF-8"%>
<html>
<head>
<title>Tutorial: Ajax</title>
<link rel="stylesheet" type="text/css" href="${f:url('/css/sa.css')}" />
<script src="${f:url('/js/jquery.js')}"></script>
</head>
<body>
 
<h1>Tutorial: Ajax</h1>
 
<input type="text" id="greeting" value=""/>
<input type="button" value="hello" onclick="$('#message').load('hello',{'greeting': $('#greeting').val()});"/>
 
<span id="message"></span><br />
 
</body>
</html>   
Everything is expanded.Everything is shortened.
  1
  2
  3
  4
  5
  6
  7
  8
 
 
 
 
 
 
 
 
<%@page pageEncoding="UTF-8"%>
<h2>Received Results</h2>
<table border=1>
  <tr>
    <th>Greeting</th>
    <td>${greeting}</td>
  </tr>
</table>

Everything is expanded.Everything is shortened.
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 
 
 
 
 
 
 
 
 
 
 
 
-
|
!
 
 
 
 
 
 
 
 
 
<%@page pageEncoding="UTF-8"%>
<html>
<head>
<title>Tutorial: Ajax</title>
<link rel="stylesheet" type="text/css" href="${f:url('/css/sa.css')}" />
<script src="${f:url('/js/jquery.js')}"></script>
</head>
<body>
 
<h1>Tutorial: Ajax</h1>
 
<script type="text/javascript">
function loadHTML() {
  $('#message').load('hello',{'greeting': $('#greeting').val()})
}
</script>
 
<input type="text" id="greeting" value=""/>
<input type="button" value="hello" onclick="loadHTML()"/>
 
<span id="message"></span><br />
 
</body>
</html>   

添付ファイル: fileajax_pattern2_2.jpg 337件 [詳細] fileajax_pattern2_1.jpg 332件 [詳細]

リロード   新規 編集 凍結解除 差分 添付 複製 名前変更   ホーム 一覧 単語検索 最終更新 バックアップ リンク元   ヘルプ   最終更新のRSS
Last-modified: 2012-08-08 (水) 23:26:15 (2928d)