Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Jan 21st, 2013  |  syntax: None  |  size: 2.03 KB  |  views: 11  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. [
  2. {
  3.     "MOD_AXL": 0,
  4.     "MOD_CDS_ID": 110000168,
  5.     "MOD_CV": 0,
  6.     "MOD_CV_CTM": null,
  7.     "MOD_ID": 168,
  8.     "MOD_MFA_ID": 514,
  9.     "MOD_PC": 1,
  10.     "MOD_PCON_END": 199007,
  11.     "MOD_PCON_START": 196303,
  12.     "MOD_PC_CTM": null,
  13.     "Name": "2 CV"},
  14. {
  15.     "MOD_AXL": 0,
  16.     "MOD_CDS_ID": 110004500,
  17.     "MOD_CV": 0,
  18.     "MOD_CV_CTM": null,
  19.     "MOD_ID": 4500,
  20.     "MOD_MFA_ID": 514,
  21.     "MOD_PC": 1,
  22.     "MOD_PCON_END": 198810,
  23.     "MOD_PCON_START": 197808,
  24.     "MOD_PC_CTM": null,
  25.     "Name": "ACADIANE"},
  26. {
  27.     "MOD_AXL": 0,
  28.     "MOD_CDS_ID": 110001660,
  29.     "MOD_CV": 0,
  30.     "MOD_CV_CTM": null,
  31.     "MOD_ID": 1660,
  32.     "MOD_MFA_ID": 514,
  33.     "MOD_PC": 1,
  34.     "MOD_PCON_END": 197712,
  35.     "MOD_PCON_START": 196301,
  36.     "MOD_PC_CTM": null,
  37.     "Name": "AMI"}
  38. // etc..etc..
  39. ]​
  40.        
  41. $(".man-select").change(function(){
  42.     var mfa_id = $(".man-select").val();
  43.     console.log(mfa_id);
  44.     $.ajax({
  45.       url: "/get_models_for_mfa/mfa_id="+mfa_id+".json",
  46.       type: "GET",
  47.       data: {},
  48.       success: function(text)   //here is object
  49.       {
  50.         console.log("getted");
  51.         $('.mod-select')
  52.          .append($("<option></option>")
  53.          .attr("value",text)
  54.          .text(text));
  55.       },
  56.       error: function(){
  57.         //alert('Ошибка javascript');
  58.       },
  59.       dataType : "html"
  60.     });      
  61.   });
  62.        
  63. success: function(text){
  64.     var your_object = JSON.parse(text);
  65.     $.each(your_object , function(k, item) {
  66.        $('.mod-select')
  67.              .append($("<option></option>")
  68.              .attr("value", item.MOD_ID)
  69.              .text(item.Name));
  70.     });
  71. }
  72.        
  73. success: function(text){
  74.     console.log("getted");
  75.     vat html = '' ;
  76.     $.each(text , function(i){
  77.         html += '<option value="' + text[i]["MOD_ID"] + '">'
  78.                            + text[i]["name"] + '</option>' ;
  79.     }
  80.     $('.mod-select').empty().append(html);
  81. }
  82.        
  83. var myData = json.d;
  84. var h = [];
  85.  
  86. $.each(myData, function(i, val) {
  87.     h.push('<option value="' + val.MOD_ID+ '">' + val.Name + '</option>');
  88. });
  89. $('#yourSelect').empty().append(h.join(''));
clone this paste RAW Paste Data