2013-10-03 2 views
-3

사용자가 단추를 클릭 할 때 제어판에서 명령을 보낼 iframe이 있습니다. 아래 코드를 사용하면 코드에 구문 오류가 있으므로 사용자가 클릭 할 때 단추가 아무 것도 나타나지 않습니다.명령의 구문 오류가 발생했습니다.

$items['googledotcom'] = array 
     (
      'description'=>'DNS resolution test', 
      '1'=>1, 
      '0'=>0, 
      'fixCommand'=>'EXC service network restart; echo "nameserver 8.8.8.8" >> /etc/resolv.conf; sleep 10; health check', 
     ); 

위의 코드 때문에이 라인의 작동하지 않습니다 에코 "네임 서버 8.8.8.8">> /etc/resolv.conf 파일;

하지만 위의 행을 제거하면 코드가 작동합니다. 하지만 위의 줄을 추가해야합니다.

구문에 대한 제안 사항이 있습니까?

감사합니다. 명령의

UPDATE

형식 : enter image description here

doCommand 자바 스크립트 :

<script type='text/javascript'> 

function doCommand(command) 
{ 
    var r=confirm("Are you sure you want to \"" + command + "\""); 
    if (!r) 
    { 
     return; 
    } 

    $.post('/device/commands-frame/', { id : '<?=$this->site->id;?>', act : command, command : command }, function(data) 
    { 
     alert('Command has been sent'); 
    }); 
} 
</script> 
+0

어떻게 그것이 작동하지 않습니다 알고 : http://jsfiddle.net/EjXmp/

그 바이올린은 다음과 같은 코드를 포함? – Phil

+0

버튼이 클릭되면 아무 일도 일어나지 않습니다. 그렇지 않으면 경고를 받게됩니다 – NewPHP

+0

* "아무 일도 일어나지 않습니다"* 매우 도움이되지 않습니다. 오류보고를 활성화 했습니까? 그 명령을 발행하려고 시도한 결과는 무엇입니까? – Phil

답변

2

이 시도 :

<?php 
$items['googledotcom'] = array 
    (
     'description'=>'DNS resolution test', 
     '1'=>1, 
     '0'=>0, 
     'fixCommand'=>"EXC service network restart; echo 'nameserver 8.8.8.8' >> /etc/resolv.conf; sleep 10; curo health check" 
    ); 
    var_dump($items); 
?> 

이 보여줍니다

array(1) { ["googledotcom"]=> array(4) { ["description"]=> string(19) "DNS resolution test" [1]=> int(1) [0]=> int(0) ["fixCommand"]=> string(103) "EXC service network restart; echo 'nameserver 8.8.8.8' >> /etc/resolv.conf; sleep 10; curo health check" } } 

지금 나는 다음과 같은 바이올린과 값을 테스트하고 그것은 작동하고 :

$(document).ready(function(){ 

$("#clickme").click(function(){ 
doCommand("EXC service network restart; echo 'nameserver 8.8.8.8' >> /etc/resolv.conf; sleep 10; curo health check"); 
}); 

function doCommand(command) 
{ 
var r=confirm("Are you sure you want to \"" + command + "\""); 
if (!r) 
{ 
    return; 
} 

$.post('/device/commands-frame/', { id : '<?=$this->site->id;?>', act : command, command : command }, function(data) 
{ 
    alert('Command has been sent'); 
}); 
} 

}); 
+0

일부 디버깅을 추가하는 것 외에는 어떻게 다릅니 까? – Phil

+0

내 로컬 호스트에서 작동하며 작동 중 ... 오류가 없습니다 ... -1 주셔서 감사합니다.) – Hackerman

+0

OP 코드는 어떻습니까? 그것 * 작동하지 않습니다 *? – Phil