新手,跨域查询订单

jerry thinkphp 2015年11月19日 收藏
通过接口实现
<meta charset="utf8">
<input type="checkbox" name="year" onclick="fun5(1)" />2015<>br/><br/><br/>
<input type="text" id="much" />订单号<br/>
<input type="button" value="查询" onclick="a()" />
<div id="show">
<table>
    <tr>
        <td>订单号</td>
        <td>派送方式</td>
        <td>派送时间</td>
        <td></td>
    </tr>
    <tr >
        <td><span id="muc" onclick="b()"></span></td>
        <td><span id="type"></span></td>
        <td><span id="tim"></span></td>
        <td><span id="goodsname"></span></td>
    </tr>
</table>
</div>
<div id="page"></div>


<script src="__PUBLIC__/jquery-1.8.3.js"></script>
<script>
    function a(){
        var much = $("#much").val();
        $.ajax({
            url:"http://www.myhtml.com/a.php?id="+much,
            type:'GET',
            dataType:'jsonp',
            jsonpCallback:'show',
            success:function(a){
                //alert(a.much)
                if(a.much == undefined){
                    $("#muc").html(a.error)
                }else{
                    $("#muc").html(a.much);
                    $("#type").html(a.type);
                    $("#tim").html(a.tim);
                }
            }
        })
    }

    function b(){
        //alert("123")
        var much = $("#much").val();
        //alert(much)
        $.ajax({
            url:"http://www.myhtml.com/b.php?id="+much,
            type:'GET',
            dataType:'jsonp',
            jsonpCallback:'show',
            success:function(a){
                    $("#goodsname").html(a.goodsname);
            }
        })
    }

    function fun5(page){
        $.ajax({
            url:"http://www.myhtml.com/c.php?id="+2015+"&page="+page+"&num="+3,
            type:'GET',
            dataType:'jsonp',
            jsonpCallback:'show',
            success:function(a){
                var op = "";
                    $.each(a,function(index,val){   // 解析出data对应的Object数组  
                        //alert()
                            op+="<li>订单号:"+val.much+"  派送方法:"+val.type+"  派送时间:"+val.tim+"</li>";
                    });
                    op = "<ul>"+op+"</ul>";
                    $("#show").html(op)
                    
            }
        })
        var page = "<a href='javascript:void(0)' onclick='fun5("+(page-1)+")'>上一页</a>  <a href='javascript:void(0)' onclick='fun5("+(page+1)+")'>下一页</a>";
        $("#page").html(page);
    }

</script>