I found an answer to a question that tells what to do, but I don't know how to implement it.
jQuery cross domain POST shenanigans
I'm programming in Django and javascript
Steps:
- ajax post to a local URL - How do I do this? Where do I post this to?
- Server code will do an HTTP POST to remote server - How do I do this in django?
- Send response to JS - I can figure that out.
Thanks
Here's an example for the $ajax function:
$.ajax({
type: "GET",
url: '/htmlApi/sendSms/',
data: {
'phone':'+12412354135',
},
success: function(data){
$("#ajaxDestination").html(data);
}
});
here's an example of a view function that posts data to the remote server:
def verify1(request):
u = request.session['user']
u.phone_number = request.GET['phone']
u.save()
apiUrl = "http://www.XXXXXXXXX.net/api/send.aspx?username=XXXXXXX&password=XXXXXX&language=1&sender=XXXXXX&mobile=" + request.GET['phone'] + "&message=" + 'ghis' + " is your verification code."
x = urllib2.urlopen(apiUrl).read()
return HttpResponse(x)
(This is an automated sms sending api call)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.