


Detailed explanation of ajax implementation of input prompt effect example
Dec 25, 2017 am 09:30 AMjs can realize the page input prompt effect, and ajax can also do it. This article mainly introduces in detail the method of ajax to realize the input prompt effect. It has certain reference value. Interested friends can refer to it. I hope it can help. Everyone.
Website home page
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <style> *{ margin:0px auto; padding:0px; } .l{ height:50px; width:198px; border-bottom:1px solid black; text-align: center; line-height:40px; vertical-align: middle; } </style> <script src="../wenjian/jquery-2.2.3.min.js"></script> </head> <body> <p style="height: 50px;width: 200px"><input type="text" id="name" style="width: 198px;height: 48px;"></p> <p id="list" style="height: 500px;width: 200px;border: 1px solid black"> <!--<p id="l">zhongguo</p>--> </p> </body> </html> <script> $("#name").keyup(function () { var n = $("#name").val(); if (n != ""){ $.ajax({ url:'ltchuli.php', data:{n:n}, type:'post', // dataType:'text', dataType:'json', success:function (data) { //text写法 // var s = data.split("|"); // var str = ""; // for (var i=0;i<s.length;i++) // { // str = str + "<p class='l'>" +s[i] +"</p>"; // } // $("#list").html(str); //json写法 for (var i in data){ $("#list").append("<p class='l'>" +data[i] +"</p>"); } } }); }else { $("#list").html(""); } }) </script>
Processing page
<?php /** * Created by fcc * User: Administrator * Date: 2017/10/30 * Time: 9:52 */ $n = $_POST['n']; require_once "../wenjian/DBDA.class.php"; $db = new DBDA(); $obj = "select region_name from region WHERE region_name LIKE '%{$n}%' "; $data = $db->Query($obj); //echo $data; echo json_encode($data);
Related recommendations:
jquery simulated title prompt effect
Practical JS form validation prompt effect_Form special effects
Based on jquery to achieve beautiful dynamic information prompt effect_jquery
The above is the detailed content of Detailed explanation of ajax implementation of input prompt effect example. For more information, please follow other related articles on the PHP Chinese website!

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

What should I do if Google Chrome prompts that the content of this tab is being shared?
![Windows input encounters hang or high memory usage [Fix]](https://img.php.cn/upload/article/000/887/227/170835409686241.jpg?x-oss-process=image/resize,m_fill,h_207,w_330)
Windows input encounters hang or high memory usage [Fix]

How to solve the 403 error encountered by jQuery AJAX request

How to solve jQuery AJAX request 403 error

How to get variables from PHP method using Ajax?

PHP vs. Ajax: Solutions for creating dynamically loaded content

Baidu Tieba app prompts that the operation is too frequent, what's the matter?

How to solve the problem of jQuery AJAX error 403?
