Category : ajax

I have a jQuery ajax call like this to get an html response and popolate an html div function loadProducts(url){ $.ajax({ type:"POST", url: url, data:{ data1: xxx }, dataType:"html",success:function(a){ $(‘#div1’).html(a); } }) } Django response in python is like this def call_view(request): if request.method == "POST": return render(request, ‘file1.html’, { ‘val1’: val1, ‘val2’: val2 }) ..

Read more

I am trying to create an image tag for a Jinja template with a variable from Ajax. success: function (response) { var pythonResponse = "<ul id=’userList’>"; $.each(response,function(index,value) { console.log(`path is ${value[0]}`) pythonResponse += `<li onClick = ‘selectUser("${value[1]}")’> ${value[1]}` pythonResponse += `<img src={{ url_for(‘static’, filename=’${value[0])}’)}}/></li>` console.log(pythonResponse); }); The line in question is this one pythonResponse += ..

Read more

I am implementing ajax in my list views page. Now I am facing problems for rendering image. How to get my image src link of each object ? views.py: class PostJsonListView(View): def get(self, *args, **kwargs): print(kwargs) upper = kwargs.get(‘num_posts’) lower = upper – 1 posts = list(Blog.objects.values(‘id’,’title’,’body’,’blog_header_image’)[lower:upper]) posts_size = len(Blog.objects.filter(is_published=’published’)) max_size = True if upper ..

Read more

jquery code $(document).ready(function(){ $(‘#submit’).click(function(){ // var From = $(‘#STN_CODE’).find(":selected").val(); if(unique.length !=0) { $.ajax({ url:"/2pointentry", method:"POST", data:{new_data:unique}, success:function(data) { $(‘#change’).html(data); $(‘#change’).append(data.htmlresponse); } }); } else { alert("Please provide the defficiences noted"); } }); }); python code def add_point2(): if request.method == "POST": print(request.form("new_data")) return render_template("newpoints2.html",form =form,name = name,details=record) please tell me how can i pass the ..

Read more

I’m very new to ajax, need help with implementing ajax to a django upvote-downvote utils function. I have tried doing it on my own but couldn’t pull it off, any help will be much appreciated thanks. Here are the code snippets: in my model: models.py class Questions(models.Model): title = models.CharField(max_length=long_len) ques_content = models.TextField() tags = ..

Read more