dcsimg
www.webdeveloper.com
Results 1 to 3 of 3

Thread: how to catch the url return value and to display?

Hybrid View

  1. #1
    Join Date
    May 2014
    Posts
    1

    how to catch the url return value and to display?

    LINK :: http://202.131.103.198:8888/poll/get-random
    · Above link will return random number every time you hit.
    · You need to write a html page which displays a button called “GET
    RANDOM”.
    · When some one clicks on that link need display fetched random number from
    that link on page using javasript/jquery without refreshing page.

  2. #2
    Join Date
    Dec 2012
    Posts
    54
    It sounds like you need ajax.
    http://api.jquery.com/jquery.ajax/

    It is an interesting assignment though as I thought ajax was excluded to same-domain policies therefore I wasn't aware JavaScript or jQuery could access an outside domain without the assistance of a page.

    I accomplished something similar by writing a php function and having it fetch the data to my domain then I used ajax to access the php on my page allowing me to get "around" the same domain restrictions.

    Other solutions I've seen involve using JSONP.

    Is this a homework assignment?

  3. #3
    Join Date
    Oct 2013
    Posts
    597
    Quote Originally Posted by sambaiahk View Post
    · You need to write a html page which displays a button called “GET RANDOM”.
    · When some one clicks on that link (ummmmm -- "button"?) need display fetched random number from that link on page using javasript/jquery without refreshing page.
    Meets the above minimum requirements:
    HTML Code:
    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="utf-8">
    <title>Random number</title>
    <script>
    	function display(rn){
    		rn.style.display = 'block';
    	}
    </script>
    </head>
    
    <body>
    
    <button onclick="display(rn)">GET RANDOM</button>
    
    <div id="rn" style="display:none;">
        <iframe width="35" height="40" src="http://202.131.103.198:8888/poll/get-random" style="border:0;"></iframe>
    </div>
    
    </body>
    </html>
    Now, you can't do anything with that number other than manually copying it to paste in another input/app/whatever. Other than that it kind of, barely, well not really, gets around the same-domain policies Lesshardtoofind mentions.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles