weixin_33696106 2016-12-07 18:37 采纳率: 0%
浏览 23

流不在$ .ajax内部

When i click on login button. Below function will be called. Execution flow is going till $.ajax but its not going inside $.ajax. Can anyone please help me on this.

$('#login').click(function() {

    var contextroot = "/services/";

    var userName = $('#userName').val();
    var password = $('#password').val();
    alert("insid ::: ");    
    $.ajax({
        url: contextroot+"login",
        dataType: 'json',
        type: 'GET',
        contentType: 'application/json',
        data: {
            userName:userName,
            password:password
        },

        success: function(data){
            sessionStorage.setItem("userName", "sharana");
            window.location.href = '/admin/index.html';
            return false;
        }
    });



});
  • 写回答

1条回答 默认 最新

  • weixin_33704234 2016-12-07 18:44
    关注

    Make available entire contextRoot in single variable as below

    $('#login').click(function() {
    
      var contextroot = '/services/login';
    
      var userName = $('#userName').val();
      var password = $('#password').val();
      alert("insid ::: ");    
      $.ajax({
        url: contextroot,
        dataType: 'json',
      ....
      ...
    
    评论

报告相同问题?