PHP Ajax不执行,代码如下

<body>

<header class="mui-bar mui-bar-nav">

    <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>

    <h1 class="mui-title">充值</h1>

    <a class="mui-action-back mui-icon mui-icon-contact mui-pull-right" href="{php echo $this->createMobileUrl('dingdanchaxun')}"></a>

</header>
<form id='form1' action="{php echo $this->createMobileUrl("pay");}" method="post">
<input type="hidden" name="vid"  id="vid">
<input type="hidden" name="money" id="money">
<input type="hidden" name="phone" id="phone">
<input type="hidden" name="type" id="type">
</form>
<div class="mui-content">

    <div class="ssp_h10"></div>
    <div class="mui-segmented-control">
        <a class="mui-control-item mui-active" href="{php echo $this->createMobileUrl('huafeichongzhi')}">话费充值</a>
        <a class="mui-control-item" href="{php echo $this->createMobileUrl('liuliangchongzhi')}">流量充值</a>
    </div>

    <div class="ssp_h10"></div>

        <div class="mui-input-row ssp_form_input">

            <input type="tel" class="mui-input-clear ssp_input" id="ssp_phone" placeholder="请输入手机号码" maxlength="11">

        </div>

        <div class="ssp_h10"></div>

        <div class="ssp_tips" id="resText" style="display: block;">请输入手机号码</div>

        <div class="ssp_h10"></div>

    <div class="ssp_note" style="display:none;color: red;text-align: center"><label>该区域暂不支持充值</label></div>



        <div class="ssp_value">

            <ul class="ssp_clear" id="PriceList">

                <li class="cur" data-realmoney="10.00"  val="10" id="mp_10"><em val="10">10</em>元</li>

                <li val="20" data-realmoney="20.00" id="mp_20"><em val="20">20</em>元</li>

                <li val="30" data-realmoney="30.00" id="mp_30"><em val="30">30</em>元</li>

                <li val="50" data-realmoney="50.00" id="mp_50"><em val="50">50</em>元</li>

                <li val="100" data-realmoney="100.00" id="mp_100"><em val="100">100</em>元</li>

                <li val="300" data-realmoney="300.00" id="mp_300"><em val="300">300</em>元</li>

            </ul>

        </div>

        <div class="ssp_h10"></div>
        {if $agent}
        <div class="ssp_price" style="display: none; font-size: 12px;"><label>原价:</label><em style=" font-size: 12px;" id="naturePrice">¥98-99.80</em>&nbsp;&nbsp;&nbsp;<label>{/if}折后价:</label><em style=" font-size: 12px;" id="mobilePrice">¥98-99.80</em></div>

        <div class="ssp_h10"></div>

        <div class="ssp_button"><button type="button" disabled class="mui-btn mui-btn-primary ssp_button_all chongzhi">充值</button></div>

        <div class="ssp_h10"></div>


    <div class="ssp_notice" style="background-color: #efeff4">

        <h4>充值说明:</h4>
        <div style=" font-size: 12px;" class="remark">
            详细说明选择相应产品。
        </div>


    </div>



</div>



</body>

$(function(){

    var phone = jQuery('#ssp_phone').val().length;//获取输入值的长度
    if(phone == 11){
        //获取id为ssp_phone的值,即手机号码
        var phone = $('#ssp_phone').val();
        $.ajax({

            type:"POST",

            url:'{php echo $this->createMobileUrl("judgephone");}',//进入到site.php/doMobileJudgephone()

            data:{phone:phone,type:1},//2表示流量

            dataType:"json",

            success: function(data){

                $('#resText').empty();   //清空resText里面的所有内容

                $('#resText').text(data.area);

                var html = '';
                if(data.valuelist.length!=0){
                    $('.chongzhi').prop('disabled', false);     //class=chongzhi的disabled属性移除
                    $('.ssp_price').show();
                    $('.ssp_note').hide();
                }else{
                    $('.chongzhi').prop('disabled', true);
                    $('.ssp_price').hide();
                    $('.ssp_note').show();
                }
                $.each(data.valuelist, function(commentIndex, comment){

                    console.log(commentIndex)


                    if(commentIndex == 0){
                        if(data.discount!=10){
                            jQuery('#mobilePrice').html('¥'+decimal(comment.realmoney*(data.discount/10),2));
                            jQuery('#naturePrice').html('¥'+decimal(comment.realmoney,2));
                            html += '<li remark="'+comment.remark+'" data-naturemoney="'+comment.realmoney +'" class="cur" data-realmoney="'+ decimal(comment.realmoney*(data.discount/10),2) +'"  id="'+ comment.vid +'"><em val="'+ comment.vid +'">'+comment.value+'</em>元</li>';

                        }else{
                            jQuery('#mobilePrice').html('¥'+comment.realmoney);
                            jQuery('#naturePrice').html('¥'+decimal(comment.realmoney,2));
                            html += '<li remark="'+comment.remark+'" data-naturemoney="'+comment.realmoney +'" class="cur" data-realmoney="'+ comment.realmoney +'"  id="'+ comment.vid +'"><em val="'+ comment.vid +'">'+comment.value+'</em>元</li>';

                        }


                    }else{
                        if(data.discount!=10){
                            html += '<li remark="'+comment.remark+'" data-naturemoney="'+comment.realmoney +'"  data-realmoney="'+ decimal(comment.realmoney*(data.discount/10),2) +'"  id="'+ comment.vid +'"><em val="'+ comment.vid +'">'+comment.value+'</em>元</li>';

                        }else{
                            html += '<li remark="'+comment.remark+'" data-naturemoney="'+comment.realmoney +'" data-realmoney="'+ comment.realmoney +'"  id="'+ comment.vid +'"><em val="'+ comment.vid +'">'+comment.value+'</em>元</li>';

                        }
                }



                });

                $('#PriceList').html(html);

            }

        });
        alert(2);
    }

})

你可以用alert()函数测试一下你的js 看是不是根本不执行 还是执行到某个地方出错导致的整体效果出不来
在不同的语句下面加一个alert函数 应该就能找到原因了 如果是根本不执行 应该就是调用的问题了

dataType:"html",你把数据类型换成html试试,我之前也遇到过类似的问题,结果别的都对,在这个数据类型上出问题了,

我建议你首先确认一下错误,是ajax压根没只想,还是ajax执行出错,如果是前者,看看phone的值是否正确,如果是后者,用ajax error看看出了什么问题

alert()一步一步测试 ,确定是哪块出了问题!