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

来自移动浏览器的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 关于#git#的问题,请各位专家解答!(相关搜索:开源项目)
      • ¥15 matlab处理脑电数据悬赏(时序图+预处理+频谱图)
      • ¥100 r语言多元回归模型怎么看表达式
      • ¥20 jenkins+sonarqube实现代码门禁时遇到的问题
      • ¥15 PMM 9010/30P
      • ¥15 pom文件依赖管理,未找到依赖
      • ¥15 现在后端返回给我一堆下载地址,都是一个视频切片后的,如何在uniapp安卓环境下将这些分片的视频下周并且合并成原始视频并下载到本地。
      • ¥15 Unity导出2D项目运行时图片变成马赛克
      • ¥15 关于communitytoolkit.mvvm的生成器得到的代码看起来没有被使用的问题
      • ¥15 matlab中此类型的变量不支持使用点进行索引