我有一个文本字段和一个显示按钮.. 我想在我在文本字段中键入一些字符串然后单击该按钮... 我可以显示来自DB的所有信息.. 这是什么代码?
$(document).ready(function){
var oTable;
$("#show").click(function(){
var params=$("#myform").serialize();
$.ajax({
async: false,
cache: false,
data: params,
success: function(res){
oTable.fnReloadAjax();
oTable.fnFilter(res);
return this;
}
});
oTable=$("#form").dataTable({............
和进程页面:
"SELECT ID,Name FROM DATA";
答案 0 :(得分:0)
$("#show").click(function(event){
oTable = $("#datalist").dataTable({
"bRetrieve" : true,
"bServerSide": true,
"bProcessing": true,
"sAjaxSource": 'showlist.php',
"fnServerData": function (sSource,aoData,fnCallback){
aoData.push({"name":"line","value":$("#showline").val()});
aoData.push({"name":"model","value":$("#showmodel").val()});
aoData.push({"name":"NIK","value":$("#showNIK").val()});
$.ajax({
"dataType":'json',
"type":'POST',
"url":sSource,
"data":aoData,
"success":function(json){
fnCallback(json);
}
});
},
这是最后的答案......
答案 1 :(得分:-1)
if (name=="")
{
document.getElementById("display").innerHTML="";
return;
}
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)
{
//$("#display").html(xmlhttp.responseText);
$("#content").attr("src" ,xmlhttp.responseText )
}
}
xmlhttp.open("GET","yazdir.php?ad="+name,true);
xmlhttp.send();
在JavaScript代码之间使用此代码。如何触发此代码我不知道但你可以使用计时器。这里是从表中获取数据的PHP代码。
--- Php Code ----
mysql_connect("localhost","admin","admin");
mysql_select_db("liste");
$query = "select * from new_table where name = '" .$_GET['ad'] . "'";
$bilgi = mysql_query($query);
while($row = mysql_fetch_array($bilgi)) {
echo $row["url"];
}