我有一个非常模糊的问题,我不知道从哪里开始.
我需要使用python(django REST调用)进行ajax登录
jQuery可以从我这里获得.
我得到了这个:
import sys, base64
import httplib, urllib, urlparse, json
auth = 'Basic %s' % base64.encodestring('%s:%s' % (username, password)).strip()
headers = {'Content-Type':'application/x-www-form-urlencoded', 'Authorization':auth}
endpoint = "urlendpoint.com"
url = "/login/"
conn = httplib.HTTPSConnection(endpoint)
conn.request("POST", url, "", headers)
response = conn.getresponse()
if response.status != httplib.OK: raise Exception("%s %s" % (response.status, response.reason))
result = json.load(response)
if "token" not in result: raise Exception("Unable to acquire token.")
if "sessionid" not in result: raise Exception("Unable to acquire session ID.")
print result["token"], result["sessionid"]
conn.close() …Run Code Online (Sandbox Code Playgroud) 我上下搜索谷歌并没有找到一个简单的解决方案.
这是我的代码的主旨:
var theArray = ["one","two","three","four"];
$('.next').click(function(){
// go forward on the array
})
$('.back').click(function(){
// do backwards on the array from the current position
})
Run Code Online (Sandbox Code Playgroud)
所以,如果用户点击"<button class="next">我会得到"一个"的警报,他们再次点击"下一个",警告"两个"等...
有快速的方法吗?