jquery - Django Ajax Values Returned but Not Being Displayed in Drop-down List -


I have a simple search box, where I use Ajax to display the blog title in the drop down suggestion list I am

I have not found any errors and when I observe the element & gt; Network & gt; Feedback via browser

Any suggestions? p> urls.py View P>

  DIF search_charts (request): if request.method == "POST": search_text = request.POST ['search_text'] other: search_text = '' article = article. Afs. Failter (title_Icient = search_text) Returns Render_ot_proning ('ajax_search.html', {'article': article})   

ajax_search.html

Articles of article {%}
  • gt; & Lt; a href = "/ {{article. slugname}} /" & gt; {{Article.title}} & lt; / A & gt; & Lt; / li & gt; {% Endfor%}

    articles.html

      {% extended "base.html"%} {% block sidebar %} & Lt; H3 & gt; Search & lt; / H3 & gt; {% Csrf_token%} & lt; Input type = "text" id = "search" name = "search" & gt; & Lt; ul id = "search-results" & gt; & Lt; / Ul & gt; {% Endblock%}   

    base.html {% load stable%}

    ajax.js

      $ (function () {$ ('#search'). ( Function () {$ .ajax ({type: "POST", url: "/ article / search /", data: {'search_text': $ ('# search'). Val (), 'csrfmiddletw': $ ( "Input [name = csrfmiddletoken]"). Val ()}, success: searchSuccess, datatype: 'html'});});}); Function Searchshoot (data, textstats, jquxhr) {$ ('# serch-results') Html (data); }   

    I do not know how this is necessary because it was a typical error rational And probably does not apply to many people, so to come along with the next person, this is probably not the solution for you, but it can be a good lesson whenever you have a bug everywhere Looking for and you are sure that you have done everything right, take a break, with fresh eyes Having come back to the problem is not it, where is it that you think.

    In this case, he was not missing the absence of success (A) from his search where $ ('serch-results') $ (' search - Result) .

    Edit: Also, on the development server of the Django I have participated in problems with AJAX and one or two other functions, where the effect of the code restriction changes is sometimes you get the server, the terminal The machine must be restarted (I recommend it in that order)

  • Comments

    Popular posts from this blog

    Verilog Error: output or inout port "Q" must be connected to a structural net expression -

    jasper reports - How to center align barcode using jasperreports and barcode4j -

    c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -