Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
http_request failing between sites
Old 08-04-2008, 06:27 PM http_request failing between sites
Extreme Talker

Posts: 196
Trades: 0
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
Code:
makeRequest('http://www.sitename.com/ajax_insert.php?field_name=test&field_value=',this.value);
This is the code in the makeRequest() function which is on Server (site) A.
Code:
function makeRequest(url, parameters) {

    http_request = false;
    if (window.ActiveXObject) { // IE
        try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
                http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
        }
    } else if (window.XMLHttpRequest) {// Mozilla, Safari,...xmlHttpReq.overrideMimeType
        http_request = new XMLHttpRequest();
        if (http_request.overrideMimeType) {
            // set type accordingly to anticipated content type
            http_request.overrideMimeType('text/xml');
        }else{ alert('Did not create *http_request.overrideMimeType*'); return false; }
    } 

    if (!http_request) {

        alert('Cannot create XMLHTTP instance');
        return false;

    }

    http_request.onreadystatechange = alertContents;

    // FOR GET VARS
    http_request.open('GET', url + parameters, true);
    http_request.send(null);
    
}
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.
</div>
empiresolutions is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 08-04-2008, 06:33 PM Re: http_request failing between sites
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
Ajax (xmlHttpRequests) can only be made inside 1 domain (I don't know about ip's though). You cannot reach another domain.
It's a security restriction that is applied by all browsers.
You either need to setup a proxy server side, or to rely on non-ajax requests.
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 08-04-2008, 06:39 PM Re: http_request failing between sites
Extreme Talker

Posts: 196
Trades: 0
hey thierry its cesar. hows it going. man this is not the great news im looking for!
</div>
empiresolutions is offline
Reply With Quote
View Public Profile
 
Old 08-04-2008, 06:41 PM Re: http_request failing between sites
Extreme Talker

Posts: 196
Trades: 0
there has to be a JS solution. i would just cURL the info but i server A is not in my control. People are placing my code on their sites and accessing a page on my server... ahh. need this to work.
empiresolutions is offline
Reply With Quote
View Public Profile
 
Old 08-04-2008, 07:14 PM Re: http_request failing between sites
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
Some work has been done offline, but if anyone want reference, EmpireSolution went the proxy route, looking for those links:

http://blog.michaelkidd.com/2007/10/php-ajax-proxy.html
http://sourceforge.net/projects/jpspan/
http://developer.yahoo.com/javascrip...oxy_simple.txt
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 08-04-2008, 07:38 PM Re: http_request failing between sites
Extreme Talker

Posts: 196
Trades: 0
thanks for the help tripy. unfortunately these methods rely on cURL, which would be great but i cannot assume all sites using my code will have cURL working.
empiresolutions is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to http_request failing between sites
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.36180 seconds with 12 queries