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 5 of 5
  1. #1
    New Coder
    Join Date
    Oct 2008
    Posts
    85
    Thanks
    7
    Thanked 2 Times in 2 Posts

    Making a Ajax request and manipulate the text

    Hi,

    I'm looking for a way to make a page request in Ajax and retrieve the request page to a string. This string should be available to any function but in the example below it isn't because alert(data); doesn't popup. After converting to a string i want to manipulate the text by using "find" to look for a string or a text in a determined area. Can this be done?

    Code:
    <input type="text" id="http" value="http://www.example.com">
    <br>
    <input type="button" id="submit" onclick="myhttp()" value="Send!"/>
    <script>
    function myhttp() {
        var http = document.getElementById("http").value;
        var dataString = 'lsd=AVrls4dL&[email protected]';
    
                $.ajax({
                type: "GET",
                url: http,
                data: dataString,
                async: false,
                success: function(data){
                alert(data);
                }
                });
                
        }
    </script>
    Thanks

  2. #2
    Master Coder sunfighter's Avatar
    Join Date
    Jan 2011
    Location
    Washington
    Posts
    7,996
    Thanks
    36
    Thanked 1,072 Times in 1,068 Posts
    I don't know if this works, but I do know getting a html website and useng data: dataString doesn't work. Try calling a php file and passing the url your looking for and using file_get_contents() and passing that back.

    In other words call a php file that has file_get_contents('THE PASSED URL')
    Evolution - The non-random survival of random variants.
    Physics is actually atoms trying to understand themselves.

  3. #3
    New Coder
    Join Date
    Oct 2008
    Posts
    85
    Thanks
    7
    Thanked 2 Times in 2 Posts
    Hi, thanks for your reply but the url must be post and using file_get_contents gives a warning of outdated browser.

  4. #4
    Master Coder sunfighter's Avatar
    Join Date
    Jan 2011
    Location
    Washington
    Posts
    7,996
    Thanks
    36
    Thanked 1,072 Times in 1,068 Posts
    PK. sory that's all I got.
    Evolution - The non-random survival of random variants.
    Physics is actually atoms trying to understand themselves.

  5. #5
    Senior Coder deathshadow's Avatar
    Join Date
    Feb 2016
    Location
    Keene, NH
    Posts
    3,345
    Thanks
    4
    Thanked 482 Times in 470 Posts
    Quote Originally Posted by tribalmp View Post
    Hi, thanks for your reply but the url must be post and using file_get_contents gives a warning of outdated browser.
    1) That means browser sniffing server side, something that shouldn't be done in the first place.

    2) if it must be "post" why was your ajax request set to "GET" in the code snippet? Could that be your problem?
    “There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies and the other way is to make it so complicated that there are no obvious deficiencies.” – C.A.R. Hoare, The 1980 ACM Turing Award Lecture
    http://www.cutcodedown.com


 

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
  •