This issue was due to Cross-Origin XMLHttpRequest
Below is my solution.
When returning from python i added the following headers
to_json = {"status": "success"}
response = HttpResponse(simplejson.dumps(to_json), mimetype="application/json")
response['Access-Control-Allow-Origin'] = "*"
return response
The same was with HttpResponseBadRequest. So the final jQuery code is as below.
$(document).ready(function(){
$("#loginForm").submit( function () {
data = $(this).serialize()
var serviceUrl = MyServiceUrl;
$.ajax({
type: "POST",
url: serviceUrl,
data: data,
success:loginSuccess,
error: loginFailure
});
return false;
});
});
function loginSuccess(data){
alert(data.status);
}
function loginFailure(data){
alert(data.status);
}
I hope it really helps someone..Cheers