简体   繁体   中英

PHP Ajax Autofill

Basically I want to create something like this: http://www.easybib.com/cite/form/website

So when you enter an URL in the textbox above it will gather information from the page and put them as values of the other textboxes below.

How is this possible using AJAX and PHP? Any ideas?

Thanks in advance.

Its not hard, but I dont want to write the code instead of you, but some starting point:

You need an html page and some javascript and a php file for ajax calls. You can start with jQuery ( http://jquery.com/ ), when you click the button you send an ajax request to the php file with the site url parameter (you read it from the textbox), and when the request finished, you populate the desired html area with the information.

In the php file, you read the url param what you sent via ajax, then you fetch the site source, for example with file_get_contents ( http://php.net/manual/en/function.file-get-contents.php ), then you can parse the html if everything succeed, and send it to the output in json, html, plaintext format (whatever you want).

Parse with SimpleXML for example ( http://php.net/manual/en/book.simplexml.php ).

There is bunch of tools and tutorials if you search with google.

Keywords: 'ajax + php', 'javascript dom manipulation', 'get site content php', 'parse html php', 'parse xml php', 'json'

Good luck.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM