Django, and JQuery (AJAX) — no response

I read the tutorial on JQuery and AJAX in particular. I wanted to tie the whole thing to Gange. Sampling began with the tutorial here:

In Django all just have this method:

def ajax(request):<br> if request.is_ajax():<br> message = 'Hello world!'<br> else:<br> message = 'Hello'<br> return HttpResponse(message)<br>
Accordingly, when trying to access the URL in browser all without problems. Jung turns itself on my machine — dev server, respectively.

Page with jQuery located on one of the free hosting services, such content:

$(document).ready(function(e) {<br> $('#ajaxButton').click(function(){<br> $('#ajaxdiv').load("http://***.***.***.***:8000/test_ajax");<br> }); <br> });<br> Like it couldn't be easier, however... Open the page on free hosting, click the button, nothing happens. In the console of the server Jangi can see that the get request successfully arrived. I looked in Firebug the response body is missing (when if you simply open a page of the server in the browser, the response body the request is — it is put the line "Hello"). This is another phenomenon for me — Jangi server receives a Get request only if I click the button in Firefox, in other browsers nothing is sent.

May be related to such problems?

Version 1.2.7 Django, jQuery 1.7.2
October 8th 19 at 00:40
1 answer
October 8th 19 at 00:42
It is impossible (without distortions) to send AJAX requests from one domain to another. More precisely, you can send, it is impossible to read the answer. It's called same origin policy (there are workarounds: JSONP and cross-origin requests). I strongly advise you to postpone learning jQuery and django and to learn the basics of HTTP, HTML, and Javascript, as well as the principles of operation of browsers. The use of frameworks does not negate the knowledge of the basics.
Ugh... after Reading about it, but when encountered — even in a head has not come. Oh, it would be at least some sort of sane error showed... Thank you, now everything works, go to teach materiel. - Collin_Mills commented on October 8th 19 at 00:45
Error in such cases written, but probably not in all browsers. Try Chrome for comparison. - antonette.Gislas commented on October 8th 19 at 00:48
$(document).ready(function(e) {




}catch(e){ alert(e) }
You will be the sane error. JQuery by default hides the error - aniya.Kertzmann65 commented on October 8th 19 at 00:51
Invalid code. load () is an asynchronous call. To catch network errors in jquery there is some option, but I don't remember what. - antonette.Gislas commented on October 8th 19 at 00:54
Yes, You are right, the load it is necessary to surround, will work exactly, Ajax catches, although asynchronous. - aniya.Kertzmann65 commented on October 8th 19 at 00:57

Find more questions by tags DjangojQuery