I am new to Django so I will try to describe my scenario the best I can:
- The user enter some String to search
- The data is returned from the server and the data is populated in the table accordingly
- The user can then click on a button and data will appear in modal dialog
- In the dialog box the user can change the search value and hit the search button to re search for the new value
- a post request is sent to the server and the function is invoked in the views file
- In the browser network under dev mode (F12) I can see that the response hold the new data but the page itself shows the old data
Does someone have an idea why this happens and how this can be resolved?
var url = "{% url "ebanalyzer:search" %}";
//window.location=url;
$.post(url,{"query" : newValue,csrfmiddlewaretoken: '{{ csrf_token }}'},function (data,status) {
//alert("data: " + data + "status: " + status)
newValue param obtain the search field value
from urls file # /search url(r'^search/$', views.post_new, name='search'),
from views file @ensure_csrf_cookie def post_new(request): print(request.POST['query']) if request.POST["query"] != '': print("Rendering") return render(request, 'ebanalyzer/index.html', {"object_list":ebInfo.getSoldItems(request.POST["query"]) })
So just to emphasize the flow, user click on "paste" button --> ajax post is performed--> post_new is invoked (so far so good) --> response return to the client side but page is not updated with new data
