加载页面上的jquery发送帖子请求

时间:2016-05-30 11:46:58

标签: javascript jquery python html ajax

我想在我的银行创建一个自动登录的html文件,这是我目前的代码:

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
<script>

var MyHeaderss = {"User-Agent":"Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.32 (KHTML, like Gecko) Chrome/48.0.2564.109 Safari/537.32",
              "X-GWT-Permutation" : "6FEFBE57C6E73F0AB33BD5A4E17945DE",
              "Content-Type":"text/x-gwt-rpc; charset=utf-8",
              "X-GWT-Module-Base": "https://www.cartetitolari.mps.it/portaleTitolari/",
              "Referer": "https://www.cartetitolari.mps.it/portaleTitolari/titolari.html"};

var login_data = '''7|0|7|https://www.cartetitolari.mps.it/portaleTitolari/|FEAC78FFDF81D6121438D70986AF1C41|portale.titolari.client.service.PTService|login|portale.titolari.client.common.login.LoginRequest/3583069702|{password}|{username}|1|2|3|4|1|5|5|0|0|6|7|'''

$.ajax({
    type:"POST",
    beforeSend: function (request)
    {
      request.setRequestHeader(MyHeaderss);
    },
    url: 'https://www.cartetitolari.mps.it/portaleTitolari/service',
    data: login_data,
    success: function(databak) {
    }
});

</script>
</head>
<body>
</body>
</html>

我需要在加载此页面时向网站发送请求并自动登录,这个请求与python有效,但我不知道如何让它在jquery中运行,我哪里出错?

1 个答案:

答案 0 :(得分:0)

您的代码是正确的。在success函数中,您可以处理来自服务的响应并设置登录。