0

I'm using jQuery's ajax post to post data from a form to an external CRM. There is an ASP.net with a C# code behind that handles the external URL.

I've done AJAX posts using this same method and have never ran into this problem. It works fine on all desktop browsers, but it freezes on iPads/iPhones and just times out on Android devices.

Here is the code for the post:

function mfSubmit(event) {
    event.preventDefault();
    if (mfValidateForm4() == true) {
    $('a#aAction').hide();
        $('#mfLoader').show();
        var campaignID = "18";
        if ($("#campID").val() != undefined) {
            campaignID = $("#campID").val();
        }
        var referID = function () {
            var myNumber = "1";
            myNumber = 70000000 + Math.floor(Math.random() * 70000000);
            return myNumber;
        };

        //alert("Campaign: " + campaignID);

        $.ajax({
            type: "POST",
            url: "/PostHelper.ashx?target=externalURL" + campaignID,
            data: {
                FirstName: firstname,
                LastName: lastname,
                Email: email,
                Phone: phone,
                PropertyZipcode: zip,
                PropertyState: state,
                CurrentCity: city,
                EstimatedHomeValue: estimatedValue,
                LoanAmount: loanAmount,
                TransactionType: loanPurpose,
                CreditRating: creditScore,
                ReferId: referID
            },
            success: function (msg) {
                //alert('SUCCESS');
                var newURL = document.location.href;
                newURL = newURL.replace('#slide-5', '#slide-6');
                document.location.href = newURL;
            },
            error: function (msg) {
                console.log(msg);
                //alert('ERROR');
            },
            datatype: 'text'
        });
    }
    return false;

}

The mfSubmit function is being called from an 'onclick' that passes the event. externalURL is just a placeholder. Also, the response from the server is just 'Success' in text format.

This is working on all desktop browsers, but will consistently freeze on Apple mobile devices and simply Timeout on Android.

Any advice or help is greatly appreciated.

4

1 回答 1

0

原来这是在 ajax 函数的 data 属性中使用的未声明变量。

虽然声明它确实解决了这个问题,但我觉得很奇怪这并没有导致基于桌面的浏览器出现任何问题。

我几乎排除了这样的事情,因为除了移动设备外它工作正常。

活到老,学到老

于 2013-08-16T20:31:13.097 回答