weixin_33682719 2015-02-18 08:54
浏览 25

Ajax提交表单不起作用

My submit button does not post the data to the $_POST. I have been browsing through the ajax form submission problems in this site, but none of the solutions posted work for my case.

JQUERY

$(document).ready(function(){
     $('form').on('submit', function(e){

          e.preventDefault();

          $.ajax({
            type: $(this).attr('method'),
            url:  $(this).attr('action'),
            data: $(this).serialize()

          });


    });
});

HTML

<form method="POST" action="add_item.php">


<div class="form-group">
    <label for="item_name">Item name </label>
    <input class="form-control" type="textfield" name="item_name" />
</div> 

<div class="form-group">
    <label for="quantity">Quantity</label>
    <input class="form-control quantity" type="textfield"     name="quantity"/> 
</div> 


<div class="form-group">
    <label for="capital">Capital</label>
     <input class="form-control capital" type"textfield" name="capital" /> 
</div> 

<div class="form-group">
    <label for="sellingprice">Selling Price</label>
   <input class="form-control sellingPrice" type="textfield" name="selling_price" /> 
</div> 

<div class="form-group">
    <button type="submit" class="btn btn-default">Submit</button>
</div>

</form>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 idea运行测试代码报错问题
    • ¥15 网络监控:网络故障告警通知
    • ¥15 django项目运行报编码错误
    • ¥15 请问这个是什么意思?
    • ¥15 STM32驱动继电器
    • ¥15 Windows server update services
    • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
    • ¥15 模糊pid与pid仿真结果几乎一样
    • ¥15 java的GUI的运用
    • ¥15 我想付费需要AKM公司DSP开发资料及相关开发。