jQuery AJAX PHP三级联动交互示例

jQuery 配合 AJAX 的三级联动,真的是前端开发中用得挺多的一种小交互。像省市区这种场景,用户一选一级,二级、三级就得跟着变,不刷新页面那种。

jQuery写事件监听方便,比如用$('#province').change()就能捕捉到用户选择省份的动作,立刻触发AJAX求,把选中的值发给PHP后端。

后端的活儿也不难,PHP拿到求参数,查下数据库,找出匹配的城市或者区县,再用echo json_encode($data)输出结果,前端拿回来直接更新就行。

像这个jquery_ajax_php_三级联动.rar资源,代码结构清晰、逻辑也顺,看得懂、改得动。想拿来改个行业分类、产品分类的场景也挺适合。

哦对了,如果你打算上线用,建议加点缓存机制,别每点一下都查数据库,性能能好不少。错误也别忘了,不然出点问题用户啥也看不到。

,这玩意儿适合刚入门 AJAX 交互的你练练手,也适合老手拿来做模板快速改。用起来还挺顺手的。

rar
jquery_ajax_php_三级联动(小生第一次用jquery).rar 预估大小:31个文件
folder
jquery三级联动 文件夹
file
hotels.sql 1KB
folder
hotels 文件夹
file
getjson.php 797B
file
index.php 2KB
folder
script 文件夹
file
jquery-1.2.6.min.js 54KB
file
jquery-1.2.6-vsdoc-cn.js 180KB
folder
json 文件夹
file
LICENSE 1KB
file
Test-JSON.php 26KB
folder
doc 文件夹
file
li_Services_JSON.html 3KB
file
todolist.html 906B
file
errors.html 3KB
file
classtrees_Services_JSON.html 3KB
file
packages.html 952B
file
blank.html 428B
folder
Services_JSON 文件夹
file
Services_JSON_UnquotedKeys_TestCase.html 4KB
file
Services_JSON_EncDec_TestCase.html 6KB
file
Services_JSON_Spaces_Comments_TestCase.html 5KB
file
_Test-JSON_php.html 6KB
file
_JSON_php.html 9KB
file
Services_JSON_Object_TestCase.html 6KB
file
Services_JSON_Empties_TestCase.html 4KB
file
Services_JSON_AssocArray_TestCase.html 6KB
file
Services_JSON_ErrorSuppression_TestCase.html 5KB
file
Services_JSON.html 11KB
file
Services_JSON_NestedArray_TestCase.html 6KB
file
Services_JSON_Error.html 4KB
file
elementindex.html 22KB
folder
media 文件夹
file
stylesheet.css 5KB
file
banner.css 425B
file
elementindex_Services_JSON.html 23KB
file
index.html 981B
file
json.class.php 33KB
rar 文件大小:104.77KB