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条回答 默认 最新

    报告相同问题?