I’m trying to create an autofill script with AJAX and the Simple HTML DOM Parser. Here’s what I have so far:
The PHP file (discogs.php):
<?php
ini_set('user_agent', 'TEST/1.0 +http://127.0.0.1/test/');
require_once('simple_html_dom.php');
// Create DOM from URL
$html = file_get_html('http://www.discogs.com/release/'.$_POST["album_id"]);
// Grab the Label
$label = $html->find('.content > a', 0);
echo $label;
// Grab the Catalogue Number
$catno = $html->find('.content', 0);
echo $catno;
// Grab the tracklist
$tracklist = $html->find('div#tracklist', 0);
echo $tracklist;
?>
To save space I’ve put the HTML and jQuery here: http://jsfiddle.net/Mobius1/cYGWs/
I know how to fill a single textarea/input by using $('element').val(data), but I can’t figure out how to fill all three inputs with the three variables from the PHP file ($label, $catno and $tracklist).
Is it possible?
First make change into script as below
Then, change your php script as below & remove you echo variable statement
Then, change your success handler function as below