tags:

views:

37

answers:

3

Hi all,

If i enter a website link in a text box and submit it i need to get that specific website details. Similarly like facebook LINK module?

Any help will be thankful

Thanks in advance

Fero

A: 

When the user enters a valid link on the text box, AJAX request back to your website to crawl the requested website for details. Then the AJAX can return details about the website back to the form.

thephpdeveloper
A: 

I would recomment to use a framework like jQuery. With jQuery you would simply:

$("#website_submission_form").submit(function() {
    $("#website_submission_form .ajax-loader-animation").show(); // Show the user something is going on...
    // You could get an animation here: http://www.ajaxload.info/

    $.ajax({
     type:  "GET",
     url:  $("#website_submission_website_input_field").attr('value'), // Warning: No parsing/validation of entered value has happened so far!
     data:  null,
     success: function(data, textStatus) {
      parseWebsiteForImgTags(data); // data contains the website html source
     },
     error:  function (XMLHttpRequest, textStatus, errorThrown) {
      alert('Something went wrong: ' + textStatus);
      $("#website_submission_form .ajax-loader-animation").hide();
     }
    });

    return false;
});
Augenfeind
could you please tell me what does "#website_submission_form" mean?I am extremely sorry. As i am a newbie i can't able to get it.
Fero
Please note also that doing ajax may have a problem on cross domain issues. Its better if you do it on server-side.
jerjer
jmaglasang is completely right - I didn't consider this cross domain problem. If you don't know what we're talking about, then better ignore my example and try that from jmaglasang!Besides that, "#website_submission_form" simply means the ID value you give your form-tag, i.e. "<form id="website_submission_form" ...>", so you can simply reference your form in your code.
Augenfeind
oh.. thanks for your guidance augenfeind and jamglasang
Fero
+1  A: 

You can try this:

<?php
   $page = file_get_contents('http://www.example.com/');
   echo $page;
   //do some stuff with $page
?>
jerjer