dongzhenshen7435 2014-09-09 07:22
浏览 55

为什么请求呈指数增长?

    echo '<tr>';
    foreach($types_show[0] as $size) {
        echo '<td>'.Form::radio('radio_size', $size->id) '</td>';
    }
    echo '</tr>';

Here is the a list of radio buttons. and I use the following ajax code to send the value to php page.

$(':radio[name=radio_size]').click(function(){
    var radio_size = $(this).val();
    $.ajax({
        type: "GET",
        url: "/management/order/edit_input",
        data: {radio_size:radio_size},
        cache: false,
        dataType: 'json',
        success: function(data) {
            $('#search_area').append(data);
        },
    });
    });

The PHP code return a view page which append to the existing #search_area. The problem is when I click a radio with id=7 first time ,it send

GET http://localhost:8008/management/order/edit_input?radio_id=7&_=1410246332142

The second time I click the radio with id=2

GET http://localhost:8008/management/order/edit_input?radio_id=2&_=1410246332143
GET http://localhost:8008/management/order/edit_input?radio_id=2&_=1410246332144

the third time you can see four.

GET http://localhost:8008/management/order/edit_input?radio_id=7&_=1410246332145
GET http://localhost:8008/management/order/edit_input?radio_id=7&_=1410246332146
GET http://localhost:8008/management/order/edit_input?radio_id=7&_=1410246332147
GET http://localhost:8008/management/order/edit_input?radio_id=7&_=1410246332148

But I only want to send it once a time.How to fix it? Thanks.

  • 写回答

1条回答 默认 最新

  • dongzhansong5785 2014-09-09 07:28
    关注

    $(':radio[name=radio_size]') selects all available radios so far. Fix it giving it name/id.

    评论

报告相同问题?

悬赏问题

  • ¥20 测距传感器数据手册i2c
  • ¥15 RPA正常跑,cmd输入cookies跑不出来
  • ¥15 求帮我调试一下freefem代码
  • ¥15 matlab代码解决,怎么运行
  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法