dongshuofu0039 2016-08-25 16:07
浏览 119

移动(iPhone 6)上的AJAX响应未显示在输入字段中

Okay so I have a piece of Ajax code that I am looping every 1 second to receive the updated value from a PHP file.

The AJAX response works fine on my laptop the value I receive back is updated in the input field for the id "Type Number", but on mobile I just receive a blank input field.

When I alert the value and test it on the mobile the alert shows the correct value, but just don't seem to be able to get the value into the input field.

Note I am using twitter bootstrap 3 for the design I am showing a different layout for xs and sm and a different one for md and lg, but the input field id's are the same, as I have to disable some input fields so they cannot run certain functions on mobile.

AJAX

<script type='text/javascript'>
var interval = 1000;
function doAjax() {
    $.ajax({
            type: 'GET',
            url: 'type_number.php',
            dataType: 'html',
            success: function (data) {
             $('#type_number').val(data);
            },
            complete: function (data) {
                    // Schedule the next
                    setTimeout(doAjax, interval);
            }
    });
}
setTimeout(doAjax, interval);
</script>

HTML

<div class='input-group'>
<span class='input-group-addon'>SIN</span>
<input type='text' name='type_number' id='type_number' class='form-control' disabled></div><br>

I have searched on here to try and find a solution but haven't came across anything, just a few responses saying that javascript on mobile is limited which I understand but I have a function in my code which is an onclick event which puts the value of a div into a input field and that works fine on the mobile. So not sure why the AJAX response can't do the same.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥30 这是哪个作者做的宝宝起名网站
    • ¥60 版本过低apk如何修改可以兼容新的安卓系统
    • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
    • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
    • ¥50 有数据,怎么用matlab求全要素生产率
    • ¥15 TI的insta-spin例程
    • ¥15 完成下列问题完成下列问题
    • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
    • ¥15 YoloV5 第三方库的版本对照问题
    • ¥15 请完成下列相关问题!