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 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Apr 2014
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Input value of a external website

    I have an application where the user enters the CPF/CNPJ, which are brazilian codes for people/companies, and I need an icon in front of this input so the user can check the situation of that code (regular, pending, suspended, canceled, null). For both codes, the website to check it are different.

    But the problem is that I can't use curl or other library because I use progress and javascript.

    To check CNPJ I included cnpj as a parameter in the page address in this model, and it works:
    Emissão de Comprovante de Incrição e de Situação Cadastral

    But for CPF is not possible to include as a parameter. Does anyone know how I can pass the value of CPF to open the page with the field already loaded? In javascript / ajax, please!

    Look, I just want the field initialized to facilitate the user's life. I don't

    The link to this query is:
    Comprovante de Situação Cadastral no CPF

  • #2
    New to the CF scene
    Join Date
    Jan 2013
    Location
    Victoria, Australia
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Blog Entries
    1
    If you are trying to access data in one domain from another domain then the answer is it can't be done because of javascript security policies relating to cross domain javascript but if you are simply trying to pass data from an input field to a popup window as a URL paramater then you can use a variation of the following...

    Code:
    <html>
    <head>
    <script type="text/javascript">
    function getCPF() {
    var cpf = document.getElementById("cpf");
    window.open("domain.com?cpf=" + cpf);
    };
    </script>
    </head>
    <body>
    <input type="input" id="cpf" />
    <input type="button" onclick="getCPF" />
    </body>
    </html>
    Hopefully that resolves your issue.

  • #3
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,079
    Thanks
    203
    Thanked 2,542 Times in 2,520 Posts
    Simply stated, the Same Origin Policy states that JavaScript code running on a web page may not interact with any resource not originating from the same web site.

    The SOP limits any AJAX XMLHTTPRequest browser call to URLs on the same server from which the host page was loaded. This means that it is impossible to make any kind of AJAX-style request to a different site than the one from which the page was loaded.

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.


  •  

    Tags for this Thread

    Posting Permissions

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