I have a php file, "php-1" which builds an html page.
It asks the user for some input The user clicks a button "getIDs" (by the way, there are several buttons with the same name)
That input is taken into a js / Ajax call, passing the input parameter to "php-2. (the passed parameter is actually assigned to the button that was clicked)
php-1
<script type="text/javascript">
jQuery(document).ready(function(){
jQuery(document).find('button#getIDs').click(function(button){
var parm1 = jQuery(this).attr('source_id');
$.ajax({
type: "POST",
url: "process-test.php?source_id="+parm1,
cache: false,
success: function(n) {
alert("complete");
}
});
});
});
</script>
"php-2" takes the POST parameter (I suppose it's really a GET) and performs an API call to an external website, which returns 2 arrays. ex. [111, 222, 333, 444, 555] and [aaa, bbb, ccc]
(I know the arrays are being built, as I saved the array contents to a server file)
The arrays are "echoed" back to the Ajax code.
php-2:
echo $results123;
echo $resultsABC;
I would like this array saved off in 2 separate files on the user's machine, prompting the user for a directory and a .txt filename, each line containing a single array element:
file 1
111
222
333
...
file 2:
aaa
bbb
ccc
How do I achieve this?
Thanks in advance!
BTW, thanks to all the SO members. You have saved me days of effort already. Hope to be able to contribute to the community.
Cheers, Simon.