common.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. jQuery.i18n.properties({
  2. name: 'lang',
  3. path: './locales/',
  4. mode: 'both',
  5. // language: 'zh_CN',
  6. checkAvailableLanguages: true,
  7. async: true,
  8. callback: function () {
  9. $("[data-i18n]").each(function () {
  10. var elem = $(this),
  11. localizedValue = jQuery.i18n.map[elem.data("i18n")];
  12. if (elem.is("input[type=text]") || elem.is("input[type=password]") || elem.is("input[type=email]")) {
  13. elem.attr("placeholder", localizedValue);
  14. } else if (elem.is("input[type=button]") || elem.is("input[type=submit]")) {
  15. elem.attr("value", localizedValue);
  16. } else {
  17. elem.text(localizedValue);
  18. }
  19. });
  20. }
  21. });
  22. function turnPage(url) {
  23. $.ajax({
  24. url: url,
  25. cache: false,
  26. success: function (html) {
  27. $("#content").html(html);
  28. },
  29. error: function () {
  30. $.ajax({
  31. type: "post",
  32. url: url,
  33. cache: false,
  34. dataType: "jsonp",
  35. jsonp: "callback", // 传递给请求处理程序或页面的,用以获得jsonp回调函数名的参数名(默认为:callback)
  36. jsonpCallback: "success_jsonpCallback", // 自定义的jsonp回调函数名称,默认为jQuery自动生成的随机函数名
  37. success: function (html) {
  38. $("#content").html(html);
  39. },
  40. error: function () {
  41. alert('fail');
  42. }
  43. });
  44. }
  45. });
  46. }