Quantcast
Channel: SharePoint 2010 - Development and Programming forum
Viewing all articles
Browse latest Browse all 11571

$.When.apply($,requests) is not working in IE 8

$
0
0

I am using below code to validate the text in the textboxes using AJAX. And when i enter the text in that textbox, immediately web service calls and returns the response and based on the response the cursor will move to respected Amount text box. Here , i am getting the alerts in Google chrome, regarding that entered account is invalid or inActive,,etc but the same code is not working in IE. 

And i need one more help i.e, We've totally 7 text boxes, if the user is entering the text in the 7th text box if the above textboxes are empty ,, we need to display the alert message like ,, please enter the text in the 1st or 2nd, 3rd,..etc which ever is empty text box.

I've written the code for the same as well but it's displaying the alerts twice even the above text box has the values..

 function AccountData(txtseq) {

        var acc;

        var accountno = "";
        var textbox = "";

        if (txtseq == "Acc1") {
            accountno = document.getElementById('<%=Acct_Number1.ClientID%>').value;
            CheckForValidAccountNo(accountno, document.getElementById('<%=Acct_Number1.ClientID%>'));
        }
.........

.........

      
        if (txtseq == "Acc7") {
            accountno = document.getElementById('<%=Acct_Number7.ClientID%>').value;
            CheckForValidAccountNo(accountno, document.getElementById('<%=Acct_Number7.ClientID%>'));
        }
    }

    // Validate the AccountNo
    function CheckForValidAccountNo(accountno, objAccTxtBox) {
             if (accountno != "") {
            var requests = [];
            var jurl = "//WebService//" + accountno;

            requests.push($.ajax({
                url: jurl,
                type: "GET",
                dataType: "text",
                beforeSend: function (xhr) {
                    xhr.setRequestHeader("Authorization", "Basic bWhrX3Jlc3R1c2VyOkJhNTkyQGpmZw==");
                }
            }));

            /*Once received the response for all the AJAX query rendering the data*/

   $.when.apply($, requests).then(function () {      // Here i am facing the issue
                      var resTrack = [];
                     resTrack.push(arguments[0]);
                var response = resTrack[0];
                if (response == 'Y') {
                    return true;
                }

                else if (response == 'N') {
                    alert("The Account Number is not in Active, please try again !!");
                    objAccTxtBox.focus();
                    return false;
                }

                else if (response == 'I') {
                    alert("InValid Account Number !!");
                    objAccTxtBox.focus();
                    return false;
                }

                else {
                    alert("Some thing Went Wrong !!");
                    objAccTxtBox.focus();
                    return false;
                }
             });     
    }

 </script>

    <tr id="acct_num1">
        <td>
              <input type="text" name="accountno" id="Acct_Number1" runat="server" onchange="newTotal()"  onblur="AccountData('Acc1')" />
                 <input type="text" id="Acct_Amount1" onkeypress="return isNumber(this);" onchange="newTotal()" onblur="newTotal()" runat="server" />
        </td>
        <td>
            </td>
        <td></td>
    </tr>
        ........................

.....................

    <tr id="acct_num7">
        <td>
            <input type="text" name="accountno" id="Acct_Number7"  runat="server" onfocusout="AccountData('Acc7')"/>
           <input type="text" id="Acct_Amount7" onkeypress="return isNumber(this);" onchange="newTotal()" onblur="newTotal()" runat="server" />
        </td>  <td> </td> <td></td>  </tr> </script>

Any help would be appreciated.

Regards,

Sureshbabu.



Viewing all articles
Browse latest Browse all 11571

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>