IgorKorytin

Untitled

Aug 16th, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.21 KB | None | 0 0
  1. <script>
  2. $(document).ready(function () {
  3.   var id = $("#service").val();
  4.   var user = $("#CUsers_id").val();
  5.   var copy = "<?php echo $copy; ?>";
  6.   var csrf = "<?php echo Yii::app()->request->csrfToken; ?>";
  7.   $.ajax({
  8.     type: "POST",
  9.     url: "/request/setfields2",
  10.     data: {"id": id, "YII_CSRF_TOKEN": csrf},
  11.     dataType: "text",
  12.     cache: false,
  13.     update: "#fields",
  14.     error: function (e) {
  15.       console.log(e);
  16.     },
  17.     success: function (data) {
  18.       $("#fields").css({'display': 'block'});
  19.       $("#fields").html(data);
  20.       if (copy != true && user) {
  21.         $.ajax({
  22.           type: "POST",
  23.           url:  "/request/getservices",
  24.           data: {"user":user, "YII_CSRF_TOKEN":csrf},
  25.           dataType: "json",
  26.           cache: false,
  27.           error: function(e) {
  28.             console.log(e);
  29.           },
  30.           success: function(json) {
  31.             $("#service").html("");
  32.             $("#service").append("<option></option>");
  33.             $.each(json, function(index, value) {
  34.               $("#service").append(
  35.                 "<option value=\"" + json[index].id + "\">" + json[index].text + "</option>"
  36.               );
  37.             });
  38.             $("#service").val(id);
  39.                     $.ajax({
  40.                       type: "POST",
  41.                       url:  "/request/contracts",
  42.                       data: {"user":user, "YII_CSRF_TOKEN":csrf},
  43.                       dataType: "json",
  44.                       cache: false,
  45.                       error: function(e) {
  46.                         console.log(e);
  47.                       },
  48.                       success: function(json) {
  49.                         $("#contract").html("");
  50.                         $("#contract").append("<option></option>");
  51.                         $.each(json.contracts, function(index, value) {
  52.                           $("#contract").append(
  53.                             "<option value=\"" + json.contracts[index].id + "\">" + json.contracts[index].text + "</option>"
  54.                           );
  55.                         });
  56.                         $("#contract").change();
  57.                       }
  58.                     });
  59.           }
  60.         });
  61.       }
  62.     }
  63.   });
  64. });
  65. </script>
Add Comment
Please, Sign In to add comment