js:

function _search() { $.ajax({ type: 'GET', url: 'frontend.views.get_content', dataType: 'json', success: function (json) { alert('success') }, error: function () { alert('error') } }); } $('.btn').click(_search); 

html:

 <button type="submit" class="btn">Search</button> 

In general, trying to make an ajax request, I get nothing - no error, no successful completion, I watch the fire bug - I see the same thing.

The question is how to track down the error , and what methods of control / debuggers can you recommend?

  • one
    url: 'frontend.views.get_content' What is it like? - romeo
  • This is from Django I tried several options {% url 'get_content'%}, it should not interfere with the error. - AlexeyAl
  • 2
    And yet, what url. Yes, and specify the following at the beginning of your function: function _search (e) {e.preventDefault (); ...}, or return false; Read - romeo
  • 2
    @AlexeyAl, and in FireBug you see how the request is sent, how is the response returned from the server? And by the way, I also do not understand your URL. Django or not, the URL structure is the same for everyone. Or are your redirection rules set up in some fashionable fashion? ----------> or return false For the form - without "or" - Deonis
  • 2
    @AlexeyAl, is the code wrapped in DOM-Ready? $ (function () {$ ('. btn'). click (_search);}); - Deonis

1 answer 1

In Firebug, in the network tab, you can find the error text. Find your request, click on it and you will see the text of the request and response. If there is not a single GET request, then something is not on the client side