Jquery

From no name for this wiki
Revision as of 16:46, 22 March 2013 by Claude (talk | contribs) (Created page with "== JQuery == <source lang="javascript"> $(function () { $("#ddlVerfuegbarePlaetze").change(function () { var option = $(this).v...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

JQuery

   $(function () {

                   $("#ddlVerfuegbarePlaetze").change(function () {

                       var option = $(this).val();

                       $.ajax({
                           type: "POST",
                           url: "Reservierung.aspx/GetAnzahlFreiePlaetze",
                           contentType: "application/json; charset=utf-8",

                           data: "{'fuehrungId':'" + option + "'}",

                           success: function (msg) {
                               fillDropDown(msg.d);
                           },
                           error: function (res, status) {
                               if (status === "error") {
                                   // errorMessage can be an object with 3 string properties: ExceptionType, Message and StackTrace
                                   var errorMessage = $.parseJSON(res.responseText);
                                   alert(errorMessage.Message);
                               }
                           }
                       });






                   });

               });
               
               function fillDropDown(freiePlatze) {
                   $("select#ddlAnzahlTeilnehmer").empty();
                   $("select#ddlAnzahlTeilnehmer").append(
                           $("<option>").val("").html("")
                   );
                   for (var i = 1; i < freiePlatze; i++) {
                       $("select#ddlAnzahlTeilnehmer").append(
                           $("<option>").val(i.toString()).html(i.toString())
                       );
                   }
               }