<a href="#" onclick="return purchaseEntry('39873');">ABC</a>
I’m planning to crawl to a web page and fetch certain contents using regex. However, this content only shows up after onclick is activated. I need to get into ABC and fetch the content. I can’t use file_get_content() because there is no link takes me to ABC page. ABC content shows up when user clicks it. Results are called via Javascript/Ajax/Json.
ABC contents are:
Name: XXXX
Address: XXXXXX
Any idea how to crawl to ABC and fetch the content?
Note: I will have to write a PHP script that crawls into remote page and fetch ABC content.
Extra info:
function purchaseEntry(customerid) {
$('customeridfield').value = customerid;
if (approvedAgents()) {
e1 = $('entrylisttable');
e1.hide();
getExistingDetails(customerid, 'confirmstatusexistingdetails');
$('confirmstatushajjlicenceno').value = '';
$('confirmstatusapproved').checked = false;
e1 = $('confirmstatus');
e1.show();
}
return false;
}
Also here is getExistingDetails:
function getExistingDetails(customerid, existingdetails) {
e1 = $(existingdetails);
e1.innerHTML = 'Loading ... <img src="/jpg/ajaxloader.gif" />';
var url = '/samex/index.php';
var pars = 'option=com_directory&view=entry2&customerid=' + customerid + '&format=raw';
new Ajax.Request(url, { method: 'get', parameters: pars,
onSuccess: function(request) {
var json = request.responseText.evalJSON();
jsondata = json['data'];
e1 = $(existingdetails);
e1.innerHTML = jsondata['clientdata'];
},
onFailure: function(request) {
e1 = $(existingdetails);
e1.innerHTML = 'Unable to get information for customer ' + customerid;
}
});
}
Any suggestions?
You can’t run JavaScript events from PHP. PHP is a server-side language, whereas HTML and JavaScript are client side languages.
The only way you can get data from the client side HTML and JavaScript is to use one of the following methods:
Use an HTML form with an action to submit data back to the server.
Use an AJAX call to send data to the server without having to reload the page.
Pull data from the $_REQUEST object when the user navigates to a different page. This assumes your data is in the link.