dtvgo28624 2019-08-13 10:42
浏览 85

使用if条件加载div的ajax成功响应数据

After for getting ajax response loading a div in the div i have radio button fields how should i write a condition inside jquery.

$.ajax({
  url: "miscellaneous_fetch.php",
  method: "POST",
  data: {
    transaction_id: transaction_id
  },
  dataType: "json",
  success: function(data, textStatus, xhr) {
    var html = '';
    html += '<div class="col-md-1"></div><div class="col-md-3"><fieldset><h5 align="left"><b>Due-Date:</b></h5><div class="radio"><label><input type="radio" name="due_date" value="none"  checked>None</label></div><div class="radio"><label><input type="radio" name="due_date" value="header" >Header</label></div><div class="radio"><label><input type="radio" name="due_date" value="body">Body</label></div></fieldset></div></div><br>';
    $('.miscellaneous_body').append(html);
  }

i want to write if condition to check with ajax response data where checked or not if checked we have to put checked tag to that field.

  • 写回答

1条回答 默认 最新

  • douguo6472 2019-08-13 13:29
    关注

    You can do like

    $.ajax({
                      url: "miscellaneous_fetch.php",
                      method: "POST",
                      data: {
                        transaction_id: transaction_id
                      },
                      dataType: "json",
                      success: function(data, textStatus, xhr) {
                     if(data == 'Your Condition'){
                     //Your CODE
                     }else{
                     //Your CODE
                      }
                }
        });
    
    评论

报告相同问题?

悬赏问题

  • ¥15 用三极管设计—个共射极放大电路
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示