Guest User

Untitled

a guest
Aug 15th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. //ajax, JSON и преобразование объекта в массив
  2. var theme = $('#select-diet-form').data('theme');
  3. var weight = $('#diet-weight option:selected').val();
  4. var weight_ajax = '&weight_ajax=' + weight;
  5.  
  6. $.ajax({
  7. url: '/wp-content/themes/' + theme + '/ajax-diet.php?select_diet=1' + weight_ajax
  8. }).done(function(result) {
  9. result = JSON.parse(result);
  10.  
  11. var array = $.map(result, function(value, index) {
  12. return [value];
  13. });
  14. });
  15.  
  16. //В php можно кодировать результат в json так:
  17. // echo json_encode($term_in_posts);
Add Comment
Please, Sign In to add comment