Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to make Ajax start a daemon on the server with the following JQuery code. The alert pops up but the daemon doesn't start. What is the proper way to format the section that is $.ajax({data: {},; to make this code work. I have been searching for hours for an example related directly to this but came up only with broad scoped and convoluted piles of generally stinky poopoo-lery:) Thanks.


I am still unable to launch the daemon. I have added a php file on the server as recommended which is called "executedp.php". It contains a script I hoped would accomplish the task. However, it has not.

Does anyone see what I am missing.

Here is the php code for executedp.php:

<?php $startDaemon = exec('sh ~/.devilspie/ $x; done'); ?>

Here is the updated JQuery code:

        if(found) {
        var xhr = $.ajax({ 
        url: 'executedg.php',
        success: alert("It has begun!")  

        switch($.tableCount) {

        case ($.tableCount = 1):'table1.html');

        case ($.tableCount = 2):'table1.html');'table2.html');

        case ($.tableCount = 3):'table1.html');'table2.html');'table3.html');

        case ($.tableCount = 4):'table1.html');'table2.html');'table3.html');'table4.html');
share|improve this question
up vote 0 down vote accepted

When you invoke the XmlHttpRequest (xhr), you must indicate an URL / URI to be executed on the remote server. In the script contained in this URI is where you have to start your daemon.

You need something more apart from just client side coding (Jquery), but also some server side scripting.

EDITED: I think you are messing the old school XmlHttpRequest and $.ajax. The code you have only makes the ajax request on the first invocation, when you define xhr. When you reference the xhr object again, inside the switch command, the ajax call is not being fired.

share|improve this answer
Ok, I created executedg.php on the server which contains: code$startDaemon = /home/dealer/gdevilspie-0.31/gdevilspie; $x; done;codeand added url: 'executedg.php' to the ajax code but still not clear on how to call it from the ajax script. – Larry Feb 21 '12 at 19:21
I think it is enough with: $.ajax({url: 'executedg.php'}); More information here: – jap1968 Feb 21 '12 at 19:36
Sorry about the code tags in the reply, not sure how to do it. @jap1968 – Larry Feb 21 '12 at 19:37
Same problem here! – jap1968 Feb 21 '12 at 19:38
Still no luck. I have updated the code with what I have done so far. @jap1968 – Larry Feb 21 '12 at 21:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .