I have this Ajax call:
$('#directory_select_form').submit(function(e) {
$('#loader').show();
$('#order_number_submit_btn').prop('disabled', true);
e.preventDefault();
$.ajax({
url: 'includes/confirmation_emails/process_directory_request.php',
type: 'POST',
dataType: 'json',
data: $(this).serialize(),
success: function(data) {
console.log(data);
$('#loader').hide();
$('#order_number_submit_btn').prop('disabled', false);
},
error: function(jqXHR, textStatus, errorThrown) {
$('#loader').hide();
$('#order_number_submit_btn').prop('disabled', false);
}
})
});
process_directory_request.php
contains a shell_exec
command:
<?php
$selected_directory = $_POST['selected']; //<-- This will be used later. Hard coded for now
$order_number = $_POST['orderId']; //<-- This will be used later. Hard coded for now.
$command = shell_exec('ssh remoteServer grep -o "Order Number 1234567" /mnt/tank/TECH/"MySQL\\ Data\\ Archives"/path/to/the/file');
echo json_encode($command);
It's crashing because for some reason it is going into an infinite loop. If I run the command from the command line, it does as it's supposed to.
I cannot use this answer because of the ssh
at the beginning. I'm running commands remotely.
What is causing this infinite loop? I don't understand. I'm printing the ajax response data to the console, and it's the same line over and over and over.
Edit Here is the output in my dev console, but it's actually many many times over:
/mnt/tank/TECH/MySQL Data Archives/path/to/the/file:Order
/mnt/tank/TECH/MySQL Data Archives/path/to/the/file:Order
/mnt/tank/TECH/MySQL Data Archives/path/to/the/file:Order
/mnt/tank/TECH/MySQL Data Archives/path/to/the/file:Order
/mnt/tank/TECH/MySQL Data Archives/path/to/the/file:Order
/mnt/tank/TECH/MySQL Data Archives/path/to/the/file:Order
/mnt/tank/TECH/MySQL Data Archives/path/to/the/file:Order
/mnt/tank/TECH/MySQL Data Archives/path/to/the/file:Order
/mnt/tank/TECH/MySQL Data Archives/path/to/the/file:Order
/mnt/tank/TECH/MySQL Data Archives/path/to/the/file:Order
/mnt/tank/TECH/MySQL Data Archives/path/to/the/file:Order
/mnt/tank/TECH/MySQL Data Archives/path/to/the/file:Order
/mnt/tank/TECH/MySQL Data Archives/path/to/the/file:Order
/mnt/tank/TECH/MySQL Data Archives/path/to/the/file:Order
/mnt/tank/TECH/MySQL Data Archives/path/to/the/file:Order
/mnt/tank/TECH/MySQL Data Archives/path/to/the/file:Order
/mnt/tank/TECH/MySQL Data Archives/path/to/the/file:Order
/mnt/tank/TECH/MySQL Data Archives/path/to/the/file:Order