common.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. loadProperties();
  2. function loadProperties() {
  3. $.i18n.properties({
  4. name: 'hupu-lang',
  5. path: 'i18n/',
  6. mode: 'map',
  7. language: $.i18n.browserLang(),
  8. callback: function () {
  9. $("[data-locale]").each(function () {
  10. $(this).html($.i18n.prop($(this).data("locale")));
  11. });
  12. }
  13. });
  14. }
  15. function turnPage(url) {
  16. $.ajax({
  17. url: url,
  18. cache: false,
  19. success: function (html) {
  20. $("#content").html(html);
  21. },
  22. error: function () {
  23. $.ajax({
  24. type: "post",
  25. url: url,
  26. cache: false,
  27. dataType: "jsonp",
  28. jsonp: "callback", // 传递给请求处理程序或页面的,用以获得jsonp回调函数名的参数名(默认为:callback)
  29. jsonpCallback: "success_jsonpCallback", // 自定义的jsonp回调函数名称,默认为jQuery自动生成的随机函数名
  30. success: function (html) {
  31. $("#content").html(html);
  32. },
  33. error: function () {
  34. alert('fail');
  35. }
  36. });
  37. }
  38. });
  39. }