あるページから別の埋め込みページに結果(POSTの戻り値)を渡したいのですが、どうすればいいのか分かりません。 ej2ファイルを持っている メインのHTMLページ(のwelcome.html)(Buttom.html):投稿結果を1つのHTMLから他のHTMLに渡すには?
のwelcome.html:
<html>
<body>
<script type = "text/javascript" src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script type = "text/javascript">
$(document).ready(function(){
$("#submit").click(function(){
xhr.open("POST", "/addGrade", true);
xhr.setRequestHeader('Content-Type', 'application/json; charset=UTF-8');
data = // logic to get the data (i skipped adding this part)
xhr.send(data);
xhr.onloadend = function() {
// HERE I WANT TO PASS THE RESULTS TO Buttom.html
};
}); // click on submit
}); // ready
</script>
<form id="gradeForm">
<p>
<label>Name:</label>
<input type="text" name="name" id="name">
</p>
<p>
<label>Grade:</label>
<input type="text" name="grade" id="grade" value="100">
</p>
<p>
<button type="button" id="submit" >submit</button>
</p>
</form>
<div>
<%include Buttom.html%>
</div>
</body>
</html>
Buttom.html:
構造は次のようになり
<head>
</head>
<body>
<script type = "text/javascript" src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script type = "text/javascript">
$(document).ready(function(){
}); // ready
</script>
<p id="ppp">
<!-- Here I want to add the results -->
<p>
</body>
POST(welcome.html内)からButtom.html(Buttom.html内のjsの機能)にどのように結果を渡すことができますか?
すでにjQueryを使用しているので、これは '$ .ajax'や' $。post'を使ってもっと簡単になり、ドキュメントの例に従います – charlietfl
HTMLはこのように動的ではありません。サーバーテクノロジーを使用するか、クッキーまたは同等のものにJavaScriptを使用してデータを格納する必要がありますが、これに対してお勧めします –
何か不足していますか? headセクションとbodyセクションを含むHTMLファイルをDIV要素サーバー側に含めても、有効なHTMLは生成されません。 – traktor53