Currently, I am in the process of developing a Django application where users should be able to initiate a partial page change by clicking a button. The challenge lies in passing data from the server to the web page without necessitating a complete page refresh, which seems tailor-made for Ajax. However, despite several attempts, I have been unable to get Ajax to function correctly within my application.
The main issue I am facing is getting the call to trigger my server-side function. Specifically, the code pertains to retrieving missed calls, with the goal of showcasing them to the user without requiring a full-page reload.
Whenever I click the button, I encounter a pop-up message stating "Something goes wrong." After inspecting the error using Firebug, it appears that there is a DAJAXICE_EXCEPTION, but unfortunately, I lack further details regarding this problem.
Can anyone shed some light on what might be causing this issue? How can I troubleshoot and resolve it effectively? Moreover, if there exists a simpler method to achieve the desired outcome without relying on the Dajax library, I would greatly appreciate any suggestions or step-by-step examples.
Server Side Function
-------- /jim/ajax.py---------
@dajaxice_register
def missedCalls(request, user):
print "Ajax:missedCalls" #never prints...
missedCalls = ScheduledCall.objects.filter(status__exact='Missed')
render = render_to_string('examples/pagination_page.html', { 'missedCalls': missedCalls })
dajax = Dajax()
dajax.assign('#calls','innerHTML', render)
return dajax.json()
-------page.html---------
<script type='text/javascript'>
function missed_calls_callback(data){
// The Dajax library expects a function as a return call.
// I'm unsure about the role of this part of the function.
// What should be included here?
alert(data.message);
}
</script>
<!-- Button -->
<input type="button" name="calltest" value="JQuery Test"
id="calltest" onclick="Dajaxice.jim.missedCalls(missed_calls_callback, {'user':{{ user }}})">
<div id="calls">
{% include "calls.html" %}
</div>
--------calls.html--------
<h2> Missed Calls</h2>
<ul>
{% for i in missedCalls.object_list %}
<li>{{ i }}</li>
{% endfor %}
</ul>