Advertisement
Guest User

Untitled

a guest
Jul 10th, 2016
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.07 KB | None | 0 0
  1. @{
  2. Layout = null;
  3. }
  4.  
  5. <!DOCTYPE html>
  6.  
  7. <html>
  8. <head>
  9. <meta name="viewport" content="width=device-width" />
  10. <title>Index</title>
  11. <script src="~/Scripts/jquery-1.10.2.min.js"></script>
  12. <script type="text/javascript">
  13.  
  14. function f1() {
  15. var token="";
  16. $.ajax({
  17. data: { webservice_username: 'hagha_saeed@yahoo.com', password: '09177173048' },
  18. url: 'http://www.travelinsure.ir/api/v1.1/authenticate',
  19. type: 'POST',
  20. dataType: 'json',
  21. success: function (data) {
  22.  
  23. $.each(data, function (idx, result) {
  24. alert(result)
  25. token = result;
  26. f2(result);
  27. })
  28. },
  29. error: function (x, y, z) {
  30. alert(x.responseText);
  31. alert(z);
  32. }
  33. });
  34.  
  35. }
  36. function f2(token) {
  37. alert('New: '+token);
  38. $.ajax({
  39.  
  40. data: { token: token },
  41. url: 'http://www.travelinsure.ir/api/v1.1/getcitylist?token=',
  42. type: 'GET',
  43. dataType: 'json',
  44.  
  45. success: function (data) {
  46. results = JSON.stringify(data);
  47. alert(results);
  48. a= JSON.parse(data);
  49. $.each(a, function (idx, result) {
  50. $("#sel").append("<option value='" + result.city_id + "'>'"+city_name+"'</option>");
  51. //alert(result.city_name);
  52. })
  53. },
  54. error: function (x, y, z) {
  55. alert(x.responseText);
  56. alert(z);
  57. }
  58. });
  59. }
  60. </script>
  61. </head>
  62. <body>
  63. <div>
  64.  
  65. <input type="submit" name="name" value="Click!!!" onclick="f1()" />
  66.  
  67. </div>
  68. <div id="mydiv">
  69. <select id="sel">
  70. <option>لیست شهرهای ایران</option>
  71. </select>
  72. </div>
  73. </body>
  74. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement