Posts

Showing posts with the label ajax

search for custom post on AJAX response in WORDPRESS

search for custom post on AJAX response in WORDPRESS I search for a post with certain $value in posts of custom post type with custom field in AJAX response. Custom field is provided by ACF plugin. When button is clicked then AJAX request is send and posts are searched through. If custom_field of a post equals $value then I get id of that post if $value doesn't exist in any of custom posts then post is created and I get id of newly created post. Every post of custom_post contains custom_field . When I refresh page it works and post is not created for second time after second click. Otherwise the another click doesn't find a post so it is created again. I don't know why refresh helps. $value custom_field $value id $value id custom_post custom_field In content-page.php I call a function from my functions.php that generates links with: content-page.php functions.php jQuery(document).ready(function($) { jQuery( "body" ).click(function( event ) { v...

Convert Json to String Arrays

Convert Json to String Arrays This is my code for my form: product name: product detail: <button id="btn" type="submit" class="btn btn-default">Submit</button> This is my javascript $(function postProduct() { $('#btn').click(function () { var productName = document.getElementById("name").value; var productDetail = document.getElementById("detail").value; var dimensions = [ productName, productDetail]; var keys = $.map(dimensions, function (value, key) { return key; }); if (productName == '' || productDetail == '') { alert("Please Fill All Fields"); } else { $.ajax({ type: 'post', url: "api/product/addproduct", data: keys, dataType: 'j...

How to get live row count as Jasper prints reports

How to get live row count as Jasper prints reports I've developed a web application using jsp that has a list of contents which are placed in an ArrayList . I've tried various methods to implement this, tried the AsynchronousFillHandle , AJAX , Scriptlet . But I just can't get it done properly. ArrayList AsynchronousFillHandle AJAX Scriptlet What I'm trying to achieve here is, while the JasperExportManager is filling records row by row, I want to display the number of rows that have been printed (say Live status of number of records printed) in the webpage. For Example 267 out of 645588 records printed 5692 out of 645588 records printed 34677 out of 645588 records printed 267 out of 645588 records printed 5692 out of 645588 records printed 34677 out of 645588 records printed After two days of unsuccessful attempts, I decided to use a shortcut, I wrote a scriptlet file, which will print the count of records being printed to a txt file in the same directory, Scriptlet ...

How to call Python functions from JavaScript in Django?

How to call Python functions from JavaScript in Django? I've been struggling on this for a couple days. I've read through many posts, blogs, and watch video demo on Django projects, but nothing quite answers my problem. I have a Django webapp that uses a Python API to connects to a third-party service to analyze text data. The user writes into a text area, presses the button, then the text is sent to the service which returns a list of JSON objects. The API call to this service is a Python function. I'm trying to use Ajax to make an async call to the Python function using the text data as a param when the button is pressed. I'm not at this time trying to invoke my third-party service, yet. I'm just trying to see if I can get a response from Python sending input and receiving output. Most of the examples I've found involve creating a form and submitting it so the Django framework automatically calls it's Python functions. A form is not exactly what I'm tr...

how do i use JSON response with Ajax

how do i use JSON response with Ajax I am trying to use the JSON response from my Ajax request, but no matter what I try i cannot get this to work so would like some help please. My code for the ajax request is below <html> <head> <title>QuizMaster</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> http://jquery-3.1.0.min.js function player(x){ var player = x; $.ajax({ url:"gameDb.php", type: "GET", data: {"request":player}, dataType: "json", success: function(data){ console.log(data); var obj = JSON.parse(data); console.log(obj[1].player1); //console.log(data['player1']);//undefined //console.log(data[player[0]]); } }); } $(document).ready(function(){ $('#button input').click(function(){ var x = this.id; player(x); }); }); With this i get the reponse ` player1.php:18 Uncaught ReferenceError...

Remove old marker add new one after call ajax method every x second with OpenLayers

Remove old marker add new one after call ajax method every x second with OpenLayers I want to change marker position for every x seconds using ajax method but i am facing 1 issue for that is the new marker is adding on OpenLayers but old marker is not removing from OpenLayers. I want to remove old marker first and then add new marker in updated place. function ShowCurrentTime() { var obj = {}; obj.device_id = $.trim($("[id*=txtdevice_id]").val()); var marker; var mapOptions; $.ajax({ url: "TRACKING.aspx/GetData", data: JSON.stringify(obj), type: "POST", dataType: "json", contentType: "application/json; charset=utf-8", success: function(data) { if (data.d != '') { var lat = data.d[1]; var lng = data.d[2]; } $.each(data, function(index, value) { ...

bind all the other three dropdowns based on firstdropdown in cshtml

bind all the other three dropdowns based on firstdropdown in cshtml This code is for binding 2 dropdowns based on the first dropdown. I want all the other three dropdowns to bind based on the first dropdown. function ByCategory(e) { $.ajax({ url: '/Admin/GetItems2', type: "GET", data: { branchname: e }, success: function(subserv) { $('#BranchCategory_BranchCategory').html(""); $('#BranchCategory_BranchCategory').append($('<option></option>').val("0").html("--Select Category--")); $.each(subserv, function(i, obj) { $('#BranchCategory_BranchCategory').append( $('<option></option>').val(obj.BranchCategory).html(obj.BranchCategory)); }); } }); } Please post your HTML code as well. – Ravi Maniyar Jun 29 at 8:35 ...

Web api Post call from ajax fails

Web api Post call from ajax fails I have an web api wand I call it method in an ajax with POST method, sending the parameter as data . It gives me a 404 not found error. But when I pass the data in the query string , it works fine. Please help me fixing the matter and get it worked when calling the method with data in the body, not the query string. Note : The web application and Web-api are running on different ports Sending a concrete type object in query string also does not work and received to web api as null config <httpProtocol> <customHeaders> <add name="Access-Control-Allow-Origin" value="*" /> <add name="Access-Control-Allow-Headers" value="Content-Type, contentType, data" /> <add name="Access-Control-Allow-Methods" value="GET, POST, PUT, DELETE, OPTIONS" /> </customHeaders> </httpProtocol> Controller public class RiskC...

How to pass the array of input images using jquery to php page? [duplicate]

How to pass the array of input images using jquery to php page? [duplicate] This question already has an answer here: I want to pass array of images or file to another php page using jquery. here is a from <form method="post" id="uploadForm" enctype="multipart/form-data" action="upload.php"> <label>Choose Images</label> <input class=" w3-input" type="file" name="images" id="images" multiple > <input type="submit" name="submit" value="UPLOAD"/> </form> now i want when i click submit button it should call jquery and pass <input class=" w3-input" type="file" name="images" id="images" multiple > this array to another page. <input class=" w3-input" type="file" name="images" id="images" multiple > i searched lot. but can't figure out how to ...