Advertisement
Guest User

Untitled

a guest
Aug 3rd, 2017
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. //login function
  2. function login (options) {
  3. // url del servlet del geoserver
  4. var url = options.server + "/geoserver/j_spring_security_check";
  5. // parametros para el login
  6. params = "username=" + options["user"] + "&password="
  7. + options["password"];
  8.  
  9. var contentType = "application/x-www-form-urlencoded";
  10. //se inicializa la petición ajax
  11. var ajax = $.ajax({
  12. data : params,
  13. type : "POST",
  14. contentType : contentType,
  15. url : url
  16. });
  17. // se ejecuta cuando la peticion finaliza
  18. ajax.done(function() {
  19.  
  20. if ($.cookie("JSESSIONID") != null && options && options.success) {
  21. options.success();
  22. }
  23. });
  24. // si ocurrio un error al realizar la peticion
  25. ajax.fail(function(data) {
  26. if (options && options.failure) {
  27. options.failure(data);
  28. }
  29. });
  30. // se ejecuta siempre al final de la petición, sin importar que esta
  31. // haya fallado
  32. ajax.always(function() {
  33. if (options && options.always) {
  34. options.always();
  35. }
  36. });
  37. };
  38. var un = prompt("enter your username","");
  39. var pw = prompt("enter your password","");
  40. login({
  41. user: un, //geoserver user
  42. password: pw,
  43. server : "http://(host server here):8080", //geoserver host
  44. success : function(){
  45. alert("Login OK!");
  46. },
  47. failure : function(){
  48. alert("Login fail!");
  49. }
  50. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement