开发者

how to retrieve and show data using .click(function()

i have one textfield and one show button.. i want after i have been type some string inside textfield then click that button... i can show all information from DB.. what's code to do th开发者_StackOverflow社区at??

$(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({............

and for process page:

"SELECT ID,Name FROM DATA";


 $("#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);
                                                                             }
                                                         });
                                           },

this is the final answer...


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();

Use this code in between your JavaScript codes. How to trigger this code I don't know but you can use timer. And here is the php code to fetch datas from table.

--- 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"];
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜