Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6

Thread: XMLHttpRequest

  1. #1
    New to the CF scene
    Join Date
    Oct 2005
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    XMLHttpRequest

    Hello everyone there,

    I have a small question. I am trying to make a request but ti do not have permision from server yet (I will). The question is, can I test it locally. I have an example of the response xml (SOAP). Is it possible to do that?

    Thank you for your help.

  • #2
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    The XHR object is restricted to the same domain policy. Hope you are taking this into account with this web service.

    How can you test locally. Save the soap message as an XML document and call it.

    Eric
    Tech Author [Ajax In Action, JavaScript: Visual Blueprint]

  • #3
    ess
    ess is offline
    Regular Coder
    Join Date
    Oct 2006
    Location
    United Kingdom
    Posts
    865
    Thanks
    7
    Thanked 29 Times in 28 Posts
    I have had the same problem where I needed to use Ajax to display a page that relied on information coming from another server.

    As it has been stated above, due to security restrictions, XMLHttpRequests must be made to the same server. But there is a hack to this, it is not the best in the world....but should solve your problem.

    To do this, you need to create a page on your server that will read contents from the source that might be located on the internet. Here is an example.

    PHP Code:
    <?php
    $url 
    $_GET['url' ];
    $var =  file_get_contents ("http://www.example.com/""r");
    echo 
    $var;
    ?>
    That is, than you can you have your XMLHttpRequest object calling that file on your server and you should be set to go..

    All the best.

  • #4
    New to the CF scene
    Join Date
    Oct 2005
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you for your answers,

    yes I know thar there are some restrictions and i will get an interface from the server, but till that I have to fake it and try the next steps. So I would like to test it locally.

    A1ien51 how can I call the xml file? with xmlhttprequest as well? I remind you that the response.xml is a SOAP file. I do not want to use php, just simple javaScript.

    Thank you for your help

  • #5
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    You save the file on your local server/computer as an XML document and you link to it in the open() method.

    Eric
    Tech Author [Ajax In Action, JavaScript: Visual Blueprint]

  • #6
    New to the CF scene
    Join Date
    Oct 2005
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you, but I cannot do it. It is supposed to be easy but anyway I always get failures.

    Can you give me a small code? Then I could get on working.

    Thank you


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •