Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. var tagTexts = $(ul li.select2-selection__choice")
  2. .toArray()
  3. .map(function(i){
  4. return i.innerText;
  5. });
  6. tagTexts = JSON.stringify(tagTexts);
  7. $.ajax({
  8. type: 'POST' ,
  9. url: '/tag/tagList',
  10. dataType: 'json',
  11. data: {
  12. tagTexts: tagTexts
  13. },
  14. error: function(err) {
  15. console.log(err);
  16. },
  17. success: function(response) {
  18. //Process Response
  19. }
  20.  
  21. });
  22.  
  23. @ResponseBody
  24. @RequestMapping(value = "/tag/tagList", method = RequestMethod.POST)
  25. public String saveTagList(HttpServletRequest request,
  26. @RequestParam(value = "searchTagTexts", required = false)String tagListString) {
  27. try
  28. {
  29. List<String> tagTexts = (List<String>)mapper.readValue(tagListString, new TypeReference<List<String>>() {});
  30. System.out.println(tagTexts);
  31. String response = tagService.saveTags(tagTexts);
  32. return response;
  33. } catch (JsonGenerationException e) {
  34. e.printStackTrace();
  35. } catch (JsonMappingException e) {
  36. e.printStackTrace();
  37. } catch (IOException e) {
  38. e.printStackTrace();
  39. }
  40. return null;
  41. }
  42.  
  43. "["Drone", "Richard Feynman, PHD", "Yatch","Tik—Tok"]"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement