首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > PHP >

请问小弟我的代码中的有关问题 ajax+php(CodeIgniter)

2013-07-29 
请教我的代码中的问题 ajax+php(CodeIgniter)我用ajax将页面的值传递到后台,但是却无法获取,请教下我这个

请教我的代码中的问题 ajax+php(CodeIgniter)
我用ajax将页面的值传递到后台,但是却无法获取,请教下我这个该怎么写呢?麻烦大牛们了。

我的页面代码为:
<script type="text/javascript">
    $(function() {
        $("form[name='estimate']").submit(function(e) {
            e.preventDefault();
            var btn = $("form[name='estimate']").find("input[type='submit']"),
                    price = $(this).find(".price");
            btn.button('loading');
            price.html("");
            $.ajax({
                type: "POST",
                url: '<?php echo base_url(); ?>index.php?module=testprice&view=getprice',
                data: $(this).serializeArray(),
                success: function(data) {
                    price.html("<h3>$" + data + " RMB</h3><h4>" + "</h4>");
                    btn.button('reset');
                },
                error: function() {
                    alert("Service Unavailable");
                }
            });
        });
       
</script>    

<!-- Body -->
<div id="body_section">
    <div id="body_section_inner">
        <div class="contentPageWrapper">
            <div class="container-fluid">


                <div id="dashboard">
                    <div class="row-fluid">
                        <div class="span12">
                            <h2>估算</h2>
                        </div>
                    </div>
                    <div class="row-fluid">
                        <form name="estimate" id="estimate" method="post" action="#" class="form-inline well well-small">
                            <div class="span9">
                                <h4>计算成本</h4>
                                <div class="row-fluid">
                                    <div class="span12">
                                        <div class="units control-group">
                                            <div class="controls">
                                                <label class="checkbox">


                                                    <small><input type="radio" name="units" value="Metric" checked="checked" autocomplete="off" /> 公制的 (kg, cm)</small>
                                                </label>
                                                &nbsp;&nbsp;
                                                <label class="checkbox">
                                                    <small><input type="radio" name="units" value="Imperial" autocomplete="off" /> 英制的 (oz, in)</small>
                                                </label>
                                            </div>
                                        </div>
                                    </div>
                                </div>


                                <div class="row-fluid">
                                    <div class="span3">
                                        <div class="control-group">
                                            <label class="control-label" for="postal_code">邮政编码</label>
                                            <div class="controls">
                                                <input type="text" class="input-small" name="postal_code" id="postal_code" value="" maxlength="5" />
                                            </div>
                                        </div>
                                    </div>
                                    <div id="estimate">
                                        <div class="span3">


                                            <div class="control-group">
                                                <label class="control-label" for="weight">重量</label>
                                                <div class="controls">
                                                    <div class="input-append">
                                                        <input type="text" class="input-mini" name="weight" value="" maxlength="6" />
                                                        <span class="add-on">kg</span>
                                                    </div>
                                                </div>
                                            </div>


                                        </div>
                                        <div class="span6">
                                            <label class="control-label" for="dimensions">尺寸</label>
                                            <div class="clearfix"></div>
                                            <div class="input-append">
                                                <input type="text" class="input-micro" name="height" value="" maxlength="6" />
                                                <span class="add-on">cm</span>
                                            </div>
                                            x
                                            <div class="input-append">


                                                <input type="text" class="input-micro" name="width" value="" maxlength="6" />
                                                <span class="add-on">cm</span>
                                            </div>
                                            x
                                            <div class="input-append">
                                                <input type="text" class="input-micro" name="depth" value="" maxlength="6" />
                                                <span class="add-on">cm</span>
                                            </div>
                                        </div>
                                    </div>


                                </div>
                                <div class="row-fluid">
                                    <div class="span5">
                                        <div class="control-group">
                                            <div class="controls">
                                                <label class="checkbox">
                                                    <input type="checkbox" name="sc" value="1" autocomplete="off" /> fsd</label>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="span7"></div>


                                </div>
                            </div>
                            <div class="span3">
                                <input type="submit" class="btn btn-inverse btn-large btn-block btn-estimate" value="" data-loading-text="" autocomplete="off" />
                                <div class="form-errors"></div>
                                <div class="price"></div>
                            </div>
                        </form>
                    </div>

                </div>

            </div>
        </div></div>
</div>

我的后台代码如下:
 function getUserPrice() {
        $tozipcode_t = $_POST('postal_code');

}

我这里无论怎样都无法获取值,请大牛帮忙分析一下,多谢多谢了
------解决方案--------------------


$tozipcode_t = $_POST['postal_code'];

热点排行