common.js 1.6 KB

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