We help IT Professionals succeed at work.

ajax jquery over vpn

KeithMcElroy
KeithMcElroy asked
on
the following returns error of 0.  
I am on a pc with vpn access to network with ip number referenced
How fix?

$(document).ready(function(){      
          $.ajax({
                type: "POST",
            url: "http://10.247.161.60/erp/xml/schema/custom.xml",
            data: xmlContent,
            contentType: "text/xml",
            dataType: "xml",
            success: function(xml){
            alert(xml.xml);
            },
            error: function(xhr){
            alert(xhr.status);
            }
      
          })
      })

Comment
Watch Question

leakim971Multitechnician
CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
what is the address of your page (the one doing the ajax call)?
it must match with : http://10.247.161.60/

Author

Commented:
It is on a desktop and needs to be. Any way to submit without same up?

Commented:
You can't do Ajax across domains you run into the same origin policy.  You need to create some sort of proxy or hack it by using a hidden iframe.

Author

Commented:
Thehidden frame sounds like the answer I was looking for. How does it work to overcome the problem.
leakim971Multitechnician
CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
use an old browser
Commented:
There are a few ways actually.

Set up a proxy...basically just a PHP script on the server that will accept your AJAX request...The proxy has the local URL to make the XML request and responds back to the client with the info.

Ditch XML and go with JSONP on the server which allows cross domain requests.  Basically you just create your function call with a callback method.  Then in the client ajax request it specifies that callback script.

You can try using CURL on the server.  Here is a good example.

http://stackoverflow.com/questions/4686497/same-origin-policy-javascript-jquery-ajax-and-retrieving-an-rss-xml-feed

Here is a good posting on using the iFrame method

http://stackoverflow.com/questions/298745/how-do-i-send-a-cross-domain-post-request-via-javascript

Author

Commented:
thank you for the breadcrumbs.  appreciated!