By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,480 Members | 1,808 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,480 IT Pros & Developers. It's quick & easy.

http_request failing between sites

100+
P: 162
im trying to call a page on "Server B" from "Server A" using http_request method. the problem is the request fails at http_request.open(). Below is the very basic code im using that can be found everywhere online.

Code Calling from a page on Server (site) A. Requesting URL is on Server (site) B
Expand|Select|Wrap|Line Numbers
  1. makeRequest('http://www.sitename.com/ajax_insert.php?field_name=test&field_value=',this.value);
  2.  
This is the code in the makeRequest() function which is on Server (site) A.
Expand|Select|Wrap|Line Numbers
  1. function makeRequest(url, parameters) {
  2.  
  3.     http_request = false;
  4.     if (window.ActiveXObject) { // IE
  5.         try {
  6.             http_request = new ActiveXObject("Msxml2.XMLHTTP");
  7.         } catch (e) {
  8.             try {
  9.                 http_request = new ActiveXObject("Microsoft.XMLHTTP");
  10.             } catch (e) {}
  11.         }
  12.     } else if (window.XMLHttpRequest) {// Mozilla, Safari,...xmlHttpReq.overrideMimeType
  13.         http_request = new XMLHttpRequest();
  14.         if (http_request.overrideMimeType) {
  15.             // set type accordingly to anticipated content type
  16.             http_request.overrideMimeType('text/xml');
  17.         }else{ alert('Did not create *http_request.overrideMimeType*'); return false; }
  18.     } 
  19.  
  20.     if (!http_request) {
  21.  
  22.         alert('Cannot create XMLHTTP instance');
  23.         return false;
  24.  
  25.     }
  26.  
  27.     http_request.onreadystatechange = alertContents;
  28.  
  29.     // FOR GET VARS
  30.     http_request.open('GET', url + parameters, true);
  31.     http_request.send(null);
  32.  
  33. }
  34.  
So what am i missing? How can i get the http_request to process a page on another server (site). FYI, outside this application, my code as written works fine.

Thank you much for all the help.
Aug 4 '08 #1
Share this Question
Share on Google+
2 Replies


rnd me
Expert 100+
P: 427
you can't. it's not allowed.
Aug 5 '08 #2

gits
Expert Mod 5K+
P: 5,343
that's right ... you may have a look here too ...

kind regards
Aug 5 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.