<a href="#" class="show_hide" style="text-align:right;">Reply</a>
<div class="slidingDiv">
<div class="container">
<div id="myDiv">
<a href="#" class="show_hide1" style="float:right; text-decoration:none; font-size:14px; font-weight:bold; color:#000;">
X</a>
<form method="post" name="form" action="">
<table width="97%" border="0">
<tr height="100px">
<td>Message</td>
<td>:</td>
<td colspan="4"><textarea name="msg" cols="50" rows="6" required></textarea></td>
</tr>
<tr height="30px">
<td>Email</td>
<td>:</td>
<td><input name="email" type="email" required/></td>
<td>Mobile</td>
<td>:</td>
<td><input name="mob" type="text" required placeholder="+91" maxlength="10"/></td>
</tr>
<tr height="30px">
<td colspan="6" align="right">
<input type="submit" value="Post" name="submit" class="submit_button" onclick="loadXMLDoc()"/></td>
</tr>
<div class="clear"></div>
</table>
<div class="clear"></div>
</form>
</div>
</div>
Ajax內容:
腳本用於顯示隱藏的div這是在while循環
<script type="text/javascript">
$(document).ready(function() {
var $slides = $(".slidingDiv").hide();
$(".show_hide").show().click(function() {
//if it is the reply link then find the next element
var $slider = $(this).next(".slidingDiv");
if (!$slider.length) {
//if the link inside the slider div is cliced then find the ancestor element
$slider = $(this).closest(".slidingDiv");
}
$slides.not($slider).stop(true, true).slideUp();
$slider.stop(true, true).slideToggle();
});
});
</script>
阿賈克斯它會發送數據到數據庫
<script type="text/javascript">
$(function() {
$(".submit_button").click(function() {
var textcontent = $("#content").val();
var dataString = 'content='+ textcontent;
if(textcontent=='')
{
alert("Enter some text..");
$("#content").focus();
}
else
{
$("#flash").show();
$("#flash").fadeIn(400).html('<span class="load">Loading..</span>');
$.ajax({
type: "POST",
url: "action.php",
data: dataString,
cache: true,
success: function(html){
$("#show").after(html);
document.getElementById('content').value='';
$("#flash").hide();
$("#content").focus();
}
});
}
return false;
});
});
</script>
<script>
function loadXMLDoc()
{
var xmlhttp;
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","ajax.txt",true);
xmlhttp.send();
}
</script>
reply.txt
消息中發送
現在的問題是,我已經while循環的答覆..所以如果im發佈在第三個回覆鏈接中,第一個回覆鏈接與msg發送了mesage一起發佈..第二個驗證不起作用drctly reply.txt msg顯示n第三個值未插入數據庫
你想這樣做:1)提交表單和數據到數據庫。 2)在DB ** HIDE **表單中成功插入數據並顯示'reply.txt'的內容。我對嗎? –
究竟是...這是我想要的..我已經做了類似的事情..但它有一些錯誤 – Pooojaaaa
你檢查了警報(xmlhttp.responseText);在if(xmlhttp.readyState == 4 && xmlhttp.status == 200) –