jquery應用執行個體

來源:互聯網
上載者:User

地理所隊列操作功能的添加記錄:

將各項功能做成子功能表,總體思路:

  ../csm/conf.php中配置所有的操作命令:

// Command to handle the queue opration

$execute_to_reconfig = $shell_cgi." ".escapeshellarg("$QUEUES_BIN/badmin reconfig");

$prepare_to_setenv = $shell_cgi." ".escapeshellarg("export LSF_ENVDIR");

$list_all_queues_command = $shell_cgi." ".escapeshellarg("source /etc/profile;$QUEUES_BIN/bqueues | $ROOT_BIN/awk '{if (NR>1)print $1}'");    // 這一句如果不加 source /etc/profile 會提示某些環境變數未設定的錯誤

$get_user_queue = $shell_cgi." ".escapeshellarg("$USR_YPBIN/bqueueadm -u %s");

$add_user_to_queue = $shell_cgi." ".escapeshellarg("$USR_YPBIN/bqueueadm -u %s -a %s");

$del_user_from_queue = $shell_cgi." ".escapeshellarg("$USR_YPBIN/bqueueadm -u %s -d %s");

$change_user_to_queue = $shell_cgi." ".escapeshellarg("$USR_YPBIN/bqueueadm -u %s -d %s -a %s");
 

 

  在相應的tpl檔案中定義顯示的視圖,注意僅僅是視圖,不包括顯示的資料。

  類似:../csm/addusertoqueue.php 是實際給tpl傳遞資料的,需要的使用者資料,隊列資料

  都是從這裡傳入的。

  類似:js/addusertoqueue.js 是利用ajax非同步將請求發送給處理頁面,並接收處理頁面傳 

  遞迴來的值。

  類似:../csm/addusertoqueue-ajax.php 是接收ajax傳來的參數,實際進行命令的執行

  的。

特別注意:$list_all_queues_command這條命令,其中限制性了source /etc/profile 把環境變數讀進去,

不然返回的數組裡面沒有值,會報錯。

Js檔案中的例子:

$().ready(function(){

$('#submit_change_user_to_queue').click(function(){

$.ajax({

url: '../csm/changeusertoqueue-ajax.php',

type: 'GET',

data: 'username='+$('#usernamelist option:selected').text()+'&beforqueue='+$('#queueslist_befor option:selected').text()+'&nowqueue='+$('#queueslist_now option:selected').text(),

dataType: 'text',

success: function(data){

alert(data);

},

error: function(XMLHttpRequest, textStatus, errorThrown){

   alert(XMLHttpRequest.status);

                 alert(XMLHttpRequest.readyState);

                 alert(textStatus);

}

});

});

});
 

 


Changeusertoqueue-ajax.php中的例子:

<?php

   include_once "../conf.php";

   include_once "../functions.php";

   include_once "../csm/conf.php";

  

   $username = $_GET["username"];

   $beforqueue = $_GET["beforqueue"];

   $nowqueue = $_GET["nowqueue"];

 

   $change_user_to_queue = $change_user_to_queue ;

   $execute_to_reconf = $execute_to_reconfig ;

   $change_user_to_queue_cmd = sprintf($change_user_to_queue,$username,$beforqueue,$nowqueue);

   $change_user_to_queue_cmd = ConstructShellCommand($change_user_to_queue_cmd);

   $execute_to_reconf_cmd = ConstructShellCommand($execute_to_reconf);

   //echo $execute_to_reconf_cmd ;

  

   ExecuteCommand($change_user_to_queue_cmd, $output, $return);

  

   if($return==0){

        ExecuteCommand($execute_to_reconf_cmd, $output, $return);

        if($return==0){

         echo "使用者".$username."已成功從隊列".$beforqueue."更改到隊列".$nowqueue."中!";        

        }else{

         echo "使配置生效的命令執行失敗!";

        }

   }else{

       echo "執行將使用者添加到指定隊列出錯,請聯絡管理員!";

   }

?>
 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.