Not Going Through The Django View Through Ajax Post Data
I am doing the login throgh ajax. jquery function is working fine but its not going to the ajax url. So django view is not getting executed. Ajax.html $(function()
Solution 1:
I would first recommend using Chrome with the developer tools console open.
You could change you alerts for console.log()
.
When your trying window.location = 'file:///android_asset/www/posts.html';
You are trying to access a local resource. If I post that in my Chrome developer tools I get back
Not allowed to load local resource: file:///android_asset/www/posts.html
If you would use window.location.replace("a url to your view");
this will work like a HTTP redirect.
for more information redirect page
and you should be able to see your view.
Solution 2:
I was made a silly mistake. I provided a wrong domain address on this page. Now it worked.
localStorage['domain'] = "http://122.172.64.142";
This address was wrong. Thats why it was not able to enter in to the view.
Solution 3:
You forgot dataType ajax param
$.ajax({
url: domain + "/login/login_android_here/",
type: "POST",
data: data,
dataType : 'json', //dataType param IS MISSINGsuccess: function (response) {
alert("success");
window.location = 'file:///android_asset/www/posts.html';
},
error: function () {
alert('some error in login');
}
});
Post a Comment for "Not Going Through The Django View Through Ajax Post Data"