-1

I am very new to ajax development, I am trying to use xhr to get and post data,the problem is when I use port based requests?

here is my working code and not working codes

$.ajax({
url : "login.php",
type : "post",
data : {
    userProfile : JSON.stringify(data)
},
success : handleDBResponse,

    error : function(jqXHR, textStatus,errorThrown) {

    console.log("The following error occured: "+ textStatus,errorThrown);
},
complete : function() {
    // console.log("user authentication
    // successful.")
}
});

this works good, but when I am using native xhr with url:port getting no response.

 function reqListener () {
 console.log(this.responseText);
    };

      var oReq = new XMLHttpRequest();
      oReq.onload = reqListener;
      oReq.open("get", "http://www.domain.com:443/akorp.css", true);
      oReq.send();

It's not working, I was debugged and I found request status is cancelled.

.htaccess file included

Access-Control-Allow-Origin:*

still I am getting the error

www.domain.com:443 not allowed by www.domain.com Access-Control-Allow-Origin etc..

what are the possible causes for this error and how to properly send request to port?

user1834809
  • 1,311
  • 4
  • 17
  • 28

1 Answers1

0

443 is the HTTPS port. Perhaps you should try an HTTPS URL instead of forcing the port.

I'm not sure I want to know why you're pulling a CSS file from somebody else's serer with xhr.

MaggieL
  • 52
  • 3