How to get response data from long polling?

Issue I do a long polling in Django (1.11). But I don’t understand why JsonResponse returns undefined values? ajax $(‘.txt_link > a’).on(‘click’, function() { $.ajax({ type: ‘GET’, url: ”, success: function(data){ console.log(data.title) //undefined } }) }) view class ProviderCreateView(CreateView): form_class

Continue reading

AJAX long-polling : How do I make this code long-polling?

Issue Originally before I understood long-polling, I had this code: var updateMessages = function() { var conv_id = []; var lastMessages = []; $(‘.user’).each(function(){ conv_id.push($(this).find(‘p’).attr(‘id’)); }); if($(‘.rightP’).find(‘.msg .msg_block’).length!=0){ $(‘.rightP’).find(‘.msg .msg_block’).each(function(){ if(($(‘.rightP’).find(‘.msg .msg_block p’).length)==0){ }else { lastMessages.push($(this).find(‘p:last-child’)[0].dataset.created_at); } }); } $.ajax({

Continue reading

NoReverseMatch at /product/pussyes/ Reverse for 'basket_adding' not found. 'basket_adding' is not a valid view function or pattern name

Issue NoReverseMatch at /product/pussyes/ Reverse for ‘basket_adding’ not found. ‘basket_adding’ is not a valid view function or pattern name. Request Method: GET Request URL: http://127.0.0.1:8000/product/pussyes/ Django Version: 1.11 Exception Type: NoReverseMatch Exception Value: Reverse for ‘basket_adding’ not found. ‘basket_adding’ is

Continue reading

Angularjs, $resource: how to get inserted object?

Issue I need to get an inserted object immediately after insertion has been done. But this is a problem with Angularjs $resource. module.factory(‘SearchQueries’, function($resource){ return $resource(‘/instances/searches/:_id’, {_id: ‘@id’}); }); var new_search = new SearchQueries({query: query}); new_search.$save(function(new_query){ console.log(new_query); console.log(new_query.id, new_query.query); console.log(new_query.$get());

Continue reading

Rating plugin pass value to AJAX

Issue I’m trying to get value to two hidden fields in AJAX which somehow is not happening. I am using http://www.wbotelhos.com/raty/ rating plugin . The value is not getting in AJAX <head> <title></title> <meta http-equiv=”Content-Type” content=”text/html; charset=UTF-8″> <script type=”text/javascript” src=”js/jquery.min.js”></script>

Continue reading

Bootstrap star-rating shown two times

Issue I am using this plugin to show star rating on my Bootstrap website. Here is part of the modal code in which I put the star rating (see the input element): <div class=”modal-header”> <button type=”button” class=”close” data-dismiss=”modal” aria-label=”Close”><span aria-hidden=”true”>&times;</span></button>

Continue reading

Javascript AJAX : node scoping

Issue I wrote this JS code : var abils = document.getElementsByName(‘aggiunta_abil’); for (let i = 0; i < abils.length; i++) { xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function() { alert(abils[i].parentNode.parentNode.innerHTML); if (xhttp.readyState == 4 || status == 200) { abils[i].parentNode.parentNode.innerHTML

Continue reading

How to call variabled ajax

Issue I put the ajax call in a variable, how can I call it again and pass some parameters to the data attribute of the ajax?. var request = $.ajax({ URL: ‘/usage_analytics.php’, type: ‘get’, data: {date_start: dt_date_start, date_end: dt_date_end}, dataType:

Continue reading

Send form inside a while with java, ajax php

Issue I have the following html code with a form <form id="msg-form-nota"> <input type="hidden" name="id_nota" id="id_nota" value="${project.id}"> <label for="textfield">Calificación obtenida:</label> <input type="text" name="nota" id="nota" class="form-control form-control-sm" value="${project.nota}" placeholder="Introducir calificación"><br> <input type="submit" name="submit" id="submit" class="btn btn-success btn-sm" value="Añadir/modificar calificación"> </form> and

Continue reading

JQuery won't fire an action from modal

Issue I have the following form in a Bootstrap modal window <form id="formCsv" class="row gy-2" enctype="multipart/form-data"> <div class="col-md-5 "> <input class="form-control" type="file" id="file" name="file"> </div> <div class="col-md-3"> <button type="submit" id="csvBtn"class="btn btn-primary" name="something"> Upload </button> </div> <div id="loading" class="clearfix col-md-2"> <div

Continue reading

Display json_encode array from ajax result

Issue I have this result {"policy":[{"id":"1","policy_name":"Policy 1","description":"Testing","status":"Active","valid_until":"2022-05-18","tags":"Test","active":"0","date_added":"2022-05-18 05:36:02"}]} And I want to display the policy_name from the array and I’ve tried to alert it using this alert(response[‘policy’].policy_name); but I have an error. 43:4801 Uncaught TypeError: Cannot read properties of undefined

Continue reading

JavaScript flow or execution

Issue If I have a JS function as follows; function testFn() { x.ajaxMethod(param1,JScallBackFunction); //Please do not worry about the syntax..this just indicates an external method call alert("Line after ajaxMethod"); } The ajaxMethod(), lets say is some kind of method defined

Continue reading

how show value of input select from database without click any button after select date?

Issue <div class="col-md-12"> <div class="form-group first"> <label >Date_reservation</label> <input type="date" name="date_res"> </div> </div> <div class="row"> <div > <div class="form-group first"> <label >Type_salle</label> <select name="code_salle" > <option>STD1</option> <option>STD2</option> <option>STD3</option> <option>STD4</option> {{– In the database there is a table of rooms. I

Continue reading

$(div).click(function) on $.ajax generated HTML

Issue I’m making a shop catalogue and the products HTML are generated through $.AJAX request on the $(document).ready(function(). $.ajax({ url: "../includes/geracatalogo.php", method: "post", data: {tipos: tipos, categorias: categorias, pagina: pagina}, success: function(html){ $("#produtos").empty(); $("#produtos").fadeOut(0); $("#produtos").append(html); $("#produtos").fadeIn(700); } }); }); Now,

Continue reading

Assign JavaScript to element from ajax query

Issue I have a simple code like: <html> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> <body> <a href="#" class="plink">Click me</a> <div class="cnt"> </div> <script> $(document).ready(function(){ $(".plink").click(function(){ alert("A"); }); $.ajax({ url: ‘do.php?a=getinfo’, type: ‘POST’, success: function(result) { $(".cnt").html(result); } }); }); </script> </body> </html> From

Continue reading

Uncaught SyntaxError: Invalid or unexpected token in ajax call

Issue I have a form which looks like this: <form id="login_form" class="border shadow p-3 rounded" method="post" style="width: 450px;"> <h1 class="text-center p-3">LOGIN</h1> <div id="error_box" class="alert alert-danger" role="alert"> </div> <div class="mb-3"> <label for="username" class="form-label">User name</label> <input type="text" class="form-control" name="username" id="username"> </div> <div

Continue reading

Django: Could not parse the remainder

Issue I’m trying to pass a response from JsonResponse as a parameter of specific function in views. But, got the following error instead django.template.exceptions.TemplateSyntaxError: Could not parse the remainder: ‘${response.id_ajuan}’ from ‘${response.id_ajuan}’ Here it is my code url.py url(r’^course-eksternal/review/(?P<id>\d+)/update$’, course_eksternal.update_ajuan,

Continue reading