2014-02-16 4 views
0

Отправляю io на сервер с YUI и как реагировать на YUI? Вот код:Как отклик от сервлета на YUI?

var user = { 
        userName: username, 
        password: password, 
        customerId: customerId 
        }; 

      var success = function (ioId, o) { 
       responseContent = Y.JSON.parse(o.responseText); 
       if (responseContent.code == 0) { 
        window.location = 'Home.jsp'; 
        } 
      }; 
      var failure = function (ioId, o) { 
       //do something 
       }; 
      var cfg = { 
        method: 'GET', 
        headers: { 
         'Content-Type': 'application/json', 
        }, 
        sync: false, 
        data: user, 
        on:  { 
         'success': success, 
         'failure': failure 
        } 
      }; 

      new Y.IO().send("http://localhost:7778/web/LoginController", cfg); 

Перенаправление не работает, и я решил перенаправить на YUI. Благодаря!!!

ответ

0
var success = function (ioId, o) { 
      responseContent = Y.JSON.parse(o.responseText); 
      if (responseContent.code == 0) { 
       window.location = 'Home.jsp'; 
       } 


      //Like this? 
      responseDiv.innerHTML = responseContent.yourData; 
     }; 
+0

Я не знаю, как передавать данные на страницу с сервлета (не на странице). –

+0

Можете ли вы сделать пример того, что вы хотите сделать? – apubaba

+0

Благодарим за помощь! Это было решено. –

Смежные вопросы