Click here to Skip to main content
15,894,540 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
good day ladies and gentlemen, I called a controller function using ajax as shown

JavaScript
function getbook()
{        $.ajax({
            type: "POST",
            url: "/Home/getBooked",
            data: { "bookNumber": mobile},
            success: function (succ) { // I need to add the items in succ to some text boxes as shown below
                $.each(succ, function (index, element) {
                        $('#tb1').val(element);
                        $('#tb2').val(element);
                    });                            },
            error: function (err) { alert("An error is thrown"); }
        });
}

but the issue is that only the last item in the parameter is shown in both text boxes.
when I used the alert function to display the contents of succ, it displayed both items.
clearly i'm missing something. i'll be glad if anyone could help
Posted

1 solution

JavaScript
success: function (succ) { 
    $('#tb1').val(succ[0]);
    $('#tb2').val(succ[1]);
}

after knocking my head around, this worked. Thanks
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900