zoukankan      html  css  js  c++  java
  • 一个js和php数据交互的例子(转)


    <script language="javascript" src="/script/script_jquery.old.js"></script>
    <script language="javascript" type="text/javascript">var j= jQuery.noConflict(true);</script>
    <option value="0">--请选择--</option>
    <!--{loop $_SGLOBAL['category'] $key $value}-->
    <option value="{$key}">{$value}</option>
    <!--{/loop}-->
    </select>
    <select name="classname2" style="WIDTH: 130px" id="classname2">
    <option value="0">--请选择--</option>
    </select>

    js:
    //获取二级分类
    function getCategory(classid){

    j.get("./xin/xin_ajax_category.php",{classid:classid},function(data){

    var results=eval("("+data+")");
    var list = document.getElementById("classname2");
    list.options.length = 0;
    list.options.add(new Option("--请选择--","0"));
    for (var i = 0; i < results.length; i++) {
    list.options.add(new Option(results[i].childname,results[i].childid)); //text ,value
    }

    });
    }
    xin_ajax_category.php:
    <?php
    include_once('../common.php');
    $classid=intval($_REQUEST['classid']);
    //flag
    if(!empty($classid)){
    $category_arr="";
    $sql="SELECT b.childid,b.childname FROM `xin_works_category_class` a, `xin_works_category_child` b WHERE a.classid=b.pid and a.classid=$classid order by a.classid ,b.childid";
    $handle=$_SGLOBAL['db']->query($sql);
    while($value=$_SGLOBAL['db']->fetch_array($handle)){

    $value['childname']=convertToUTF8($value['childname']);
    $category_arr[]=$value;

    unset($value);

    }
    unset($handle);
    //print_r($category_arr);
    echo json_encode($category_arr);
    }
    ?>
    当你一步一个脚印的走过
  • 相关阅读:
    nginx article
    学习历程
    GRPC
    学习记录
    JAVA知识点记录
    flag
    读的文章
    This usually happens because your environment has changed since running `npm install`.
    expandedRowKeys、expandedRowsChange、expand
    服务端高并发分布式架构演进之路
  • 原文地址:https://www.cnblogs.com/Alviss/p/4450171.html
Copyright © 2011-2022 走看看