开发者

$.ajax not working in IE, it is fine in Firefox

开发者 https://www.devze.com 2023-02-24 05:51 出处:网络
<script src=\"https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js\"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script language="javascript">  

    function funcSendSMS(numbers, smsmessage)
    {
    alert(numbers);
      var num = numbers;
      var开发者_JS百科 msg = smsmessage;
  $.ajax({  
    type: "GET",  
    url: "http://sms.vrksolutions.com/messageapi.asp",  
    data: "username=xxxxxx&password=xxxxxx&sender=xxxxxx&mobile="+num+"&message="+msg,
    async: false,
    cache: false,
    success: function(resp){  
      // we have the response  
      alert("Server said:\n '" + resp + "'");  
    },  
    error: function(e){  
      alert('Error: ' + e);  
    }  
  });  
}  
</script>
<script  language="javascript">
funcSendSMS('<?php echo $phnos ?>', '<?php echo $smsmsg;?>');
</script>

I got below error in IE

Webpage error details

User Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; Trident/4.0; GTB6.6; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.2) Timestamp: Tue, 12 Apr 2011 13:22:58 UTC

Message: Access is denied.

Line: 138 Char: 355 Code: 0 URI: https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js

at this lane i found

below code in min.js file

A.src=b.url;if(!d){var C=false;A.onload=A.onreadystatechange=function(){
if(!C&&(!this.readyState||this.readyState==="loaded"||this.readyState==="complete"))
{C=true;c.handleSuccess(b,w,e,f);c.handleComplete(b,w,e,f);
A.onload=A.onreadystatechange=null;r&&A.parentNode&&r.removeChild(A)}}}
r.insertBefore(A,r.firstChild);return B}var J=false,w=b.xhr();
if(w){b.username?w.open(h,b.url,b.async,b.username,b.password)
:w.open(h,b.url,b.async);try{if(b.data!=null&&!l||a&&
a.contentType)w.setRequestHeader("Content-Type",


try this:

$(function(){
     funcSendSMS('<?php echo $phnos ?>', '<?php echo $smsmsg;?>');
});

or

function Load() {
            var a = false;
            try {
                var test = $('*');
                if(test == null)
                    throw 1;
            }
            catch (e) { a = true; }
            if (a){setTimeout(Load, 300);return;}

            funcSendSMS('<?php echo $phnos ?>', '<?php echo $smsmsg;?>');
        } 
setTimeout(Load, 300);

Make sure you are not doing a cross domain request through AJAX.


http://sms.vrksolutions.com/messageapi.asp

I'm going to guess that it's a cross domain scripting issue. You can't do a regular AJAX call from one domain to another for security reasons. This article should set you straight on the security issues and how to get started with JSONP.

0

精彩评论

暂无评论...
验证码 换一张
取 消