Im getting nothing really... I just do alert(response); and nothing shows up.
quarta-feira, 18 de Fevereiro de 2015 às 14:48:48 UTC, Vijay Khemlani escreveu: > > What is the actual content of the response you are getting from the AJAX > request? > > On Wed, Feb 18, 2015 at 10:27 AM, João Marques <joao669...@gmail.com > <javascript:>> wrote: > >> Hey guys, so basicly I want to send a GET request with ajax to one of my >> views and the specific view returns an html response that will be loaded on >> a div. >> The problem is that is doesn't seems to work at all. Nothing happers on >> the div. >> >> Please help me community! Thank you! >> >> >> *HTML to be filled with the response:* >> >> <div id="content"></div> >> >> >> *GET REQUEST:* >> >> $.ajax({ >> type: 'GET', >> url: 'saveToDbAndReturn', >> data: {sols: holder} >> }).done(function (response) { >> document.getElementById("content").innerHTML = >> response; >> >> }); >> >> >> >> *VIEW:* >> >> def saveToDbAndReturn(request): >> >> if(request.GET.get('sols', ''))=='': >> return HttpResponseRedirect("/") >> else: >> sols = json.loads(request.GET.get('sols', '')) >> >> >> for i in range(0, len(sols)): >> >> new_entry = Solution(fullArray=sols[i]) >> new_entry.save() >> >> return render_to_response('saveToDbAndReturn.html', {'sols': sols}) >> >> >> *saveToDbAndReturn.html* >> >> <div class="panel panel-default"> >> >> {% for i in range(sols) %} >> >> <div class="panel-heading" role="tab" id="heading{{i}}"> >> <h4 class="panel-title"> >> <a data-toggle="collapse" data-parent="#accordion" >> href="#collapse{{i}}" aria-expanded="true" aria-controls="collapse{{i}}"> >> {{i}} >> </a> >> </h4> >> </div> >> <div id="collapse{{i}}" class="panel-collapse collapse in" >> role="tabpanel" aria-labelledby="heading{{i}}"> >> <div class="panel-body"> >> {{sols[i]}} >> </div> >> </div> >> {% endfor %} >> >> </div> >> >> >> *Variable sol*: >> >> Just so you get an idea, the array sols is someting like this [ [[1, 2] , >> [3,4]] , [[4,5,6],[2,21,9]] ] >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Django users" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to django-users...@googlegroups.com <javascript:>. >> To post to this group, send email to django...@googlegroups.com >> <javascript:>. >> Visit this group at http://groups.google.com/group/django-users. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/django-users/a4a2f0f7-0f6c-4918-8c01-669ff9a0f563%40googlegroups.com >> >> <https://groups.google.com/d/msgid/django-users/a4a2f0f7-0f6c-4918-8c01-669ff9a0f563%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> For more options, visit https://groups.google.com/d/optout. >> > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/0d917e98-68f5-4c1e-b1ff-9065e9b8e89e%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.