2011-04-26 2 views
0

이 코드는 구문 오류를 생성합니다 ..하지만 무엇이 잘못 됐는지 알 수 없습니까?eval() - 구문 오류

alert(eval('('+this.responseText+')')); 

편집 : 당신은 responseText실제로 유효 자바 스크립트 여부를 확인해야 할 것입니다

 var _this = this; 
     this.resource.open('POST', uri, true); 
     this.resource.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); 
     this.resource.onreadystatechange = function(){ 
      if(this.readyState == 4){ 
       _this.clear_timeout(); 

       if(_this.loader){ 
        Loader.dstr(); 
       } 

       if(_this.rtn_func){ 
        _this.rtn_func(eval('('+this.responseText+')'), _this.rtn_obj, _this.rtn_scope); 
       } 
      } 
     }; 
     this.resource.send(get_str); 
+0

아마, 당신의 응답 텍스트의 값이 어떤 유효한 자바 스크립트 ... – Vishwanath

+2

가없는 경우 현명한 responseText? –

+0

예 물론! : D 대답을 – clarkk

답변

1

. 이 responseText은 어디에서 오는 이상 제어를하지 않는

, 즉 A의
alert(this.responseText); 

나는 당신을 말해야 것을 : 당신은 확실히 당신은 표시을 실행하기보다는 캐릭터에 싶지 않았다 있습니까 C130 항공기를 통과하기에 충분히 큰 구멍 :-)

0
a= eval("("+this.responseText+")"); 
alert(a); 

위 코드 부분을 시도하십시오. 희망이 도움이 될 것입니다.

0

대괄호가 원인입니다. 이 시도.

alert(eval(this.responseText)); 
1

_this.rtn_func (평가 ('('+ this.responseText + ')') _this.rtn_obj, _this.rtn_scope);

평가판은 스크립트를 직접 실행합니다. 12 + 3 + 4

그 형태

eval('(12 + 3 + 4)') 

이 있어야 작업 등 이러한 유 가지고 응답. u는 같은 시도되는

다른 리턴 기능 이름으로 응답 텍스트 또는 다른 일부 문자열 데이터의 표시 오류가

eval('(formdata())')