YUI 3 Haciendo una llamada AJAX desde un clic de botón y rellenando cuadros de texto

Estoy utilizando ASP.NET MVC 3 con Razor. And I am using YUI 3.4.1.

I have a web page with a button on it with textboxes. When the user clicks on a button I do a AJAX call to the database and then the textboxes are filled with the returned data (on the same page as this button). It is currently being done using jQuery. Below is the code, how would I do the same thing using YUI 3.4.1? What do I need to look into and are there are already samples available?

Aquí está el código actual:

$('#btnPrepopulateEmployeeDetails').click(function () {
     var url = '/GrantApplication/GetEmployeeInfo';
     var data = { employeeNumber: $('#EmployeeNumber').val() };

     $.getJSON(url, data, function (data) {

btnPrepopulateEmployeeDetails is the id of the button tag. Title thru CellphoneNumber are all textboxes that need to be populated.

I appreciated all feedback :)

preguntado el 08 de noviembre de 11 a las 11:11

1 Respuestas

It would have been nice to show what you have tried so far and what difficulties you have encountered. As far as samples are concerned the documentación is pretty abundant on them. Suffice to read.

De todas formas:

Y.on('load', function (e) {
    Y.one('#btnPrepopulateEmployeeDetails').on('click', function (evt) {
        var data = { employeeNumber: Y.one('#EmployeeNumber').get('value') };
        Y.io('/GrantApplication/GetEmployeeInfo', {
            method: 'GET',
            data: data,
            on: {
                success: function (id, result) {
                    var json = Y.JSON.parse(result.responseText);
                    Y.one('#Title').set('value', json.Title);
                    Y.one('#FirstName').set('value', json.NickName);
                    Y.one('#LastName').set('value', json.Surname);
                    Y.one('#BranchNumber').set('value', json.BranchID);
                    Y.one('#WorkTelephoneNumber').set('value', json.TellO);
                    Y.one('#CellphoneNumber').set('value', json.TellC);

respondido 08 nov., 11:17

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.