Guest User

erg

a guest
Jul 5th, 2016
36
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. loadPrivateMessages: function() {
  2. var response = '';
  3. var form_data = {
  4. username: "username",
  5. password: "password"
  6. };
  7. $.ajax({
  8. type: "POST",
  9. url: "js/ajax.php",
  10. data: form_data,
  11. success: function(response)
  12. {
  13. response = '[{"Language":"jQuery","ID":"1"},{"Language":"C#","ID":"2"},{"Language":"PHP","ID":"3"},{"Language":"Java","ID":"4"},{"Language":"Python","ID":"5"},{"Language":"Perl","ID":"6"},{"Language":"C++","ID":"7"},{"Language":"ASP","ID":"8"},{"Language":"Ruby","ID":"9"}]';
  14. console.log(response);
  15.  
  16. var json_obj = $.parseJSON(response);//parse JSON
  17.  
  18. var output="<ul>";
  19. for (var i in json_obj)
  20. {
  21. output+="<li>" + json_obj[i].Language + ", " + json_obj[i].ID + "</li>";
  22. }
  23. output+="</ul>";
  24.  
  25. $('#messages').html(output);
  26. },
  27. dataType: "json"//set to JSON
  28. })
  29. },
Add Comment
Please, Sign In to add comment