helloxielan 2017-11-07 13:16 采纳率: 0%
浏览 21

来自移动浏览器的Ajax调用

I have searched a lot but no solution worked for me.

I'm working on a captive portal with pfsense that means a user will need to fill out a form whenever they connect to our network before they recieve free internet. What I'm doing is taking some data from user and making an ajax Get request (using jQuery 3.2.1) to a web service (based on asp.net web api).

Everything works fine when I do it on a computer although it doesn't work on mobile browsers. I don't know why but somehow data doesn't go to web services when we use mobile phones.

This is my javascript code.


function uploadData(){      
  var PhNumber = document.getElementById("customerPhone").value;
  var cName = document.getElementById("customerName").value;
  var Url="http://192.168.1.155/customer/api/Values?customerName="+cName+"&customerPhone="+PhNumber+"";
  var exp = /^((\+92)|(92)|(0092))-{0,1}\d{3}-{0,1}\d{7}$|^\d{11}$|^\d{4}-\d{7}$/;
  var cNum = exp.test(PhNumber);



if (exp.test(PhNumber)) {

    $(function () {

            $.ajax({
                type: 'GET',
                url : Url,                    
                cache : 'false',
                dataType:'xml',                                     

                success: function (responce) {
                    return alert("Data Saved");
                },
                failure: function() {
                    alert("Some Error Acured");
                }
             });
        });                      
    }
}
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 slam rangenet++配置
    • ¥15 对于相关问题的求解与代码
    • ¥15 ubuntu子系统密码忘记
    • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
    • ¥15 保护模式-系统加载-段寄存器
    • ¥15 电脑桌面设定一个区域禁止鼠标操作
    • ¥15 求NPF226060磁芯的详细资料
    • ¥15 使用R语言marginaleffects包进行边际效应图绘制
    • ¥20 usb设备兼容性问题
    • ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊