2013-04-11 2 views
0

다음은 jquery 항목입니다. REST 서비스를 호출하고 응답 결과가 AJAX Success 이벤트로 돌아 가기 위해 올바르게 작동합니다.AJAX에서 변수 값이 업데이트되지 않습니다.

하지만 실행될 때마다 변수 "SelectedVal"(document.getElementById ('Text1'). value)가 업데이트되지 않고 처음으로 설정된 값으로 유지됩니다.

이벤트는 첨부되어 있으며 클릭 할 때마다 업데이트되지 않습니다. 해결 방법은?

jQuery(document).ready(function() { 
var selectedVal = ''; 
var date = new Date(); 
var d = date.getDate(); 
var m = date.getMonth(); 
var y = date.getFullYear();  

    var calendar = jQuery('#calendar').fullCalendar({ 
     header: { 
      left: 'prev,next today', 
      center: 'Plan Issues', 
      right: 'month,agendaWeek,agendaDay' 
     }, 
     selectable: true, 
     selectHelper: true, 
     select: function(start, end, allDay) { 

       AJS.$(document).ready(function() {      

       var dialog = new AJS.Dialog({ 
       width: 400, 
       height: 300, 
       id: "planissues-dialog", 
       closeOnOutsideClick: true 
      }); 

      // PAGE 0 (first page) 
      // adds header for first page 
      dialog.addHeader("Plan Issues"); 

      // add panel 1 
      dialog.addPanel("Issues Planning", "<table><tr><td>Enter issues ID (separated by comma):</td><td><input id='Text1' type='text' /></td></tr></table>", "panel-body"); //PROBLEM: "Text1" control is added here in dialog. 

dialog.addButton("Submit", function (dialog) 
{ 
selectedVal = document.getElementById('Text1').value; //PROBLEM:This returns every time same value even though, entering different value while dialog is popup. it preserve same value which was enter during first time and then after on each consequence , it remains same value. 
if (selectedVal != '') { 
alert(selectedVal);  // PROBLEM: alert shows same value which set at first time. 
var url = "http://localhost:2990/jira/rest/restresource/1.0/message/save/" + selectedVal; 


jQuery.ajax({ 
      type: "POST", 
      url: url, 
      contentType: "application/json", 
      dataType: "json", 
      data: "finaldatapassed", 
      cache: false, 
      success: function (resp, status, xhr) { 
       alert('in success JSON');     
       alert(status); //success 

      }, 
      error: function(resp, status, xhr){ 
        alert('in error json'); 
        alert("Error: " + resp.e); 
      } 
     }); 
}              
}); 

}); 마우스 오른쪽 -

+6

이 _ _ "이 변수를 업데이트하지 않습니다"시도

Type: Function(PlainObject data, String textStatus, jqXHR jqXHR) 

으로 정의된다. 왜냐하면 당신의 코드에서는 아무 것도하지 않기 때문입니다. 문맥의 응답에서 무엇을 할 지 짐작하기는 어렵지만'document.getElementById ('Text1')와 같은 값을 가진'success' 핸들러에서 뭔가를해야합니다. value = resp.someProperty ; '(REST 서비스가 JSON을 반환하는 경우 JSON (한 번 구문 분석 된)이 원하는 값의 속성을 가짐). – nnnnnn

+0

위 기능을 호출하는 코드를 게시 할 수 있습니까? –

+0

나는 그가 상태 변수를 의미한다고 생각한다. – laktak

답변

0

성공은

success: function (data) { 
      alert('in success JSON');     
      alert(data); //success 
     }, 
+0

나는 또한 '함수 (데이터)'를 시도했지만 작동하지 않았다. – dsi

+0

다른 가능한 원인을 알려주세요.이 문제는 아직보고 있습니다. – dsi

+0

더 많은 정보를 제공해야합니다. 예 : '작동하지 않는다'고 말하는 대신 정확히 무슨 일이 일어나는지 말해주십시오. – laktak

관련 문제