ajax,checkbox,label , Trouble dynamically changing state of checkbox with AJAX

Trouble dynamically changing state of checkbox with AJAX


Tag: ajax,checkbox,label

I am trying to have to check boxes through ajax, but it is not working properly. I am not able to change state of the first checkbox, only the second one is working fine. Could anyone spot the error here?

    contentType:"application/json; charset:utf-8",
    success: function(data){
        .append("<tr rowspan='2' class='domainname'>
                      <th class='domainname'>Domain Name</th>
                      <th class='domainname'>Is this domain applicable to your organization?</th>
                      <th style='height:30px' class='domainname'>Do you want this domain to be displayed?</th>
        var index = 0;

            var index2=index+1;

            var display_status = "";
            var applicable_status = "";
            if(data[i].applicable == 1){
                applicable_status = "checked";
            if(data[i].display == 1){
                display_status = "checked";

        .append("<tr class='domainname'>
                    <td class='domainname'>
                       <a href='setcategoryapplicability.php?dom="+ data[i].domid +"'>"+ data[i].domname +"</a>
                         <input id='toggle-"+index+"' name='applicable["+data[i].domid+"]' class='toggle toggle-round' type=checkbox "+applicable_status+">
                             <label for='toggle-"+index+"]'></label>
                        <input id='toggle-"+index2+"' name='display["+data[i].domid+"]' class='toggle toggle-round' type=checkbox "+display_status+">
                             <label for='toggle-"+index2+"'></label>
            index = index +2;
    complete: function(){

enter image description here


I am so sorry to trouble you guys. I feel so stupid. Thank you for your responses. It is working fine now. enter image description here


jquery - add header request to specific ajax request

I need to add some header details to one specific ajax request that one of the third party control will make. The third party control allows me to set the URL but it does not allow me to add header information to the request. So far I am able to...

How to dynamically add a row without “Requested unknown parameter” error

I am new to DataTables and I am having problems in dynamically adding a new row to the datatable. Here is my initialization: table = $("#college-list").DataTable({ 'ajax': { 'url': 'admin/get_college', 'type': 'GET' }, 'columns': [ { 'data': 'college_abbrev', "bSortable": true }, { 'data': 'college_name' , "bSortable": true }, { "mData":...

How to add checkbox to uicollectionview in swift

some time ago someone already asked this question and a few answers were given but i didn't really understand any of them. So i was wondering if anyone could please write an easy to understand tutorial on how to do the things shown on the image below: http://i.imgur.com/BzIBOkH.jpg?1 I would...

Using $.ajaxStop() to determine when page is finished loading in CasperJS

So far in my tests written in CasperJS, I've been using waitForSelector() on page-specific elements to determine if a page has fully loaded (including all the async ajax requests). I was hoping to come up with a more standard way of waiting for page load and was wondering if the...

How to transform $.post to $.ajax?

I have this $.post peace of code: $.post("../admin-login", { dataName:JSON.stringify({ username:uname, password:pass, }) }, function(data,status){ console.log("Data:"+data); answer = data; } ); and I wont to transform it to $.ajax. On the servlet side I am demanding request.getParamter("dataName") but I do not know how to write data: section in $.ajax so...

Why are fields reset after ajax update with Primefaces

On a form I have some personal information (name, address etc.) and a changeListener which updates the salutation and letter salutation according to the gender and last name. If the underlying entity was already stored in the database it works fine. If I'm entering data for a new (not saved)...

How to write .htaccess file for AJAX page

I am working on a website which i am going to develop as a CMS. So i am writing .htaccess file. page link and url working fine, but when i performing ajax request then i am getting 404 error for the url. I am placing my .htaccess file code and...

WooCommerce seems to only orderby date and not price

I am loading in variable products via a custom WP_Query $args = array( 'post_type' => 'product', 'posts_per_page' => 100, 'product_cat' => 'beast-balls', 'orderby' => 'date', 'order' => 'desc' ); $loop = new WP_Query( $args ); if ( $loop->have_posts() ) { while ( $loop->have_posts() ) : $loop->the_post(); ?> <div class="product-node cat-beast-balls">...

checkbox updating another checkbox on different form

my first javascript is not working, hope you can help. I am trying to make a checkbox on one form check a checkbox on another form. This is based on this link: check/uncheck checkbox based on another checkbox Here is my simplified code <formname="A" action="WebPage.php" method="POST"> <input type="checkbox" name="Aa" onchange="update()"...

Getting a collection via Ajax to show in view

All I'm trying to do is have a collection populate in the view when a user clicks a button. But I feel like I'm making this way too complicated and it's not working. See my code - where am I going wrong? Click handler: $('#filterrific_results').find('.followup-injury').on('click', function(e){ e.preventDefault(); $.ajax({ url: "/assessments/followups",...

Storing result from FOR loop as one array (array only saves each results seperately)

I have tried searching but can't find anything to help, maybe my problem is too simple! Anyway, I'm running an ajax request. The data given to the request is an array. Here is my code: var id = "1#2#3#4#5#"; var chkdId = id.slice(0, -1); var arr = chkdId.split('#'); var checkedId...

Check AJAX response data before taking action

I have an AJAX call to a PHP script that returns either the content of a Bootstrap3 modal, or an HTML form. PHP code - (ajax.php): if ($numLegs == 1) { echo $formData; } else { echo $modalContent; } If it returns $formData, I want to display the form data,...

Modal won't close on ajax success

I'm loading in the content of a modal with ajax. I have a button that submits the modal form and is suppose to close the modal when it's done processing the ajax submit so it can update a table at the bottom of the page. It's not closing the modal...

How to trigger ajax loading with an observable varariable in knockout?

I got some tabs in a page. When clicking on a tab, the currentTab changes its value, which should trigger an ajax loading of a new tab content. The concept is similar to a ko.computed, which however, only update another variable as the value change takes place. Is there any...

How to load two PHP scripts simultaneously using jQuery?

I have an upload feature that is made up of various different stages, and the duration of this upload can be quite lengthy. To increase usability of this feature, I want to present the user with information concerning the progress of the upload. The upload is processed through jQuery, and...

Load page and input values

Is it possible somehow to open url, without loading it. Let me explain, I'm creating check-box which will let to create new log and automtically input values. I know how to take boxes and input value into them using javascript. But i don't know how to open that page without...

Automatically calling server side class without

I have an anchor which calls a server side class when clicked, but I want to modify it so that the class is called as soon as the page loads, without having to click an anchor. <a href="#" class="_repLikeMore" data-id="1234" data-type="pid" data-app="forums"> ...

Sending LIst via ajax to complex model

I know I've done this before but I can't seem to get this to work. I have the following JavaScript; $("#btnTestVouchers").click(function () { var postData = { "workplaceGiverId": $(".wpgDropdownList").val(), "fromMemberId": $(".wpgFromMemberDropdownList").val(), "toMemberId": $(".wpgToMemberDropdownList").val(), "voucherExpiryDate": $("#expiryDatePicker").val(), "recipients": JSON.stringify("[{'firstname':'a','lastname':'b','email':'c','voucheramount':'d'}]") }; console.log(postData); $.ajax({ type: "POST", url:...

file input type not being included in jquery FormData for AJAX send

I have a simple form that will be sent via AJAX to a php file for processing, this form includes a file upload, for some reason the file upload is not being included in the data to be sent. My html form: <form id="business-form"> <label for="business-name">Business Name:</label> <input type="text" id="business-name"...

Can I uniquely identify 2 check boxes so that I can add a different image to each?

Currently I am using an image for checked and unchecked checkboxes the html and css is below. <div class="text-field-box text-field-box-mobile radio-button-box small"> <asp:CheckBox ID="ChkOffer1" text=" " runat="server" class="checkbox checkbox-mobile radio" Visible="true" EnableViewState="true"></asp:CheckBox> <% Response.Write(Session("Offer1"))%> </div> and css input[type=checkbox] { display:none; } input[type=checkbox] + label { background-image: url("checkbox-default.png"); background-repeat: no-repeat;...

ajax test not working

I tried to get a simple ajax-test working but without success. I am trying to pass a variable($add1) from PHP to JS, then let the JS calculate the sum and return it back to a PHP variable via $_POST and ECHO it out in the html. index.php: <?php echo "<script...

Multiple AJAX forms with the same ID on the same page

I have two AJAX newsletter subscribe forms on the same page (top and bottom). Both forms have the same ID. The top form works perfectly, however I'm unable to get the alert messages to appear in the bottom form. I found this question but wasn't sure how to implement the...

.NET wep api won't accept %2E or . in api request uri

We're trying to create our first web api using the .net framework. To try this we've used this demo project: http://www.codeproject.com/Articles/549152/Introduction-to-ASP-NET-Web-API In this project we've changed the find() function of the AJAX script so it only sends one var to our new democontroller.: <script> var uri = 'api/Demo'; function find()...

Loading external php file in a div with jquery ajax

i am making a simple project..and i need to load data from other page in an index.php..and i have set time of 20sec. but its not working.. could u please tell me what is wrong with the query..Thanks already.. index.php <?php include 'connection.php'; ?> <html> <head> <title> My First Chat...

Identifier starts immediately after numeric literal

I'm trying to get the current logged in usersID in my jquery function var userID = @User.Identity.GetUserId(); Many answers on this page say that I have to do something like \"@User.Identity.GetUserId()\" But it dont seem to work, can someone tell me how to fix it. Its for my ajax post....

Disable 2 buttons after click of a button

I have a submit button on page index.php When i click this button another script (call.php) is called through ajax that holds some response. Now i want that time between the click of submit button and response displayed/received under a div through the call of ajax script the buttons option1...

Making an alert() with PHP and ajax

I have an ajax function that submits some data to my PHP file. In my PHP file I have some checks that it does with that data, I then try to make an alert to come up to say something. I can't get any alerts to come up though. All...

Run AJAX function on form submit button after javascript confirm() cancel

I have a form where and AJAX function runs on form submission to make sure that the data in the form doesn't conflict with data in the database. If a conflict is found, the AJAX function pops up a confirm() box. If the user clicks "OK", the form is submitted....

Unable to upload file to Sharepoint @ Office 365 via REST

I'm having trouble creating/uploading files via Microsoft's REST API (or at least that's what they call it) for Sharepoint running on Office 365. It looks like I'm able to authenticate all right, but I'm getting 403 Forbidden when I try to create a file. The same user can upload a...

access the json encoded object returned by php in jquery

I want to post some data to php function by ajax, then get the encoded json object that the php function will return, then I want to get the information (keys and values) from this object, but I don't know how, here is my code: $.ajax({ url: "functions.php", dataType: "JSON",...

Parameters from f:param not submitted with AJAX request when form enctype is multipart/form-data

I'm running Wildfly 8.2 and I'm using the JSF version bundled with it, 2.2.8-jbossorg-1. I have the following facelet: <h:form enctype="multipart/form-data"> <h:commandButton value="Submit"> <f:param name="myparam" value="true"/> <f:ajax execute="@this" render="@this"/> </h:commandButton> </h:form> When I press the submit button, several parameters are submitted, but not myparam. If I remove enctype="multipart/form-data" from the...

my done button somehow went to a blank page and delete won't work unless I refresh -ajax

I am playing around with a todo list I learned online. Trying to add ajax into it. Works well when I try to add an item. When an item is added there's a button says 'Mark as done' so I can click on it and then there will be a...

How use jquery getJSON with a local variable

i want to extend the completions of Ace Editor, and i need a json of word, this is my code: function load_completions() { var object = $('#preview').attr('class'); $.ajax({ type: "POST", url: "test_editor_ajax.php", data: {action:'load_completion', object:object}, cache: false, success: function(json){ var adminCompleter = { getCompletions: function(editor, session, pos, prefix, callback) {...

How to return value in Meteor.JS from HTTP.call “GET”

I'm writing a meteor method, which should return a Facebook response for HTTP.call on graph api, but HTTP.call has only a callback function to show error/response, so I can't take this data outside, and Method can not return any value. Here's my method code: loadUserFBEvents: function () { var accessToken...

Jquery html page dynamic control and load

I am cremating HTML table with some complex logic so i have create html page for row like GridRow.html and one main page which contents table tag i load GridRow.html page using ajax request and get result as string html,in that page we have some select option list i need...

Get all images from local folder

I need a way to get all the images from a local folder for a presentation that will also run locally. There will be no attempt for a server to take the images from a local folder since that is not possible/the case. I need to use .js since I...

Jquery parsley validate not working

if($("#dataform").parsley().isValid()){ $.ajax({ url : '<?php echo base_url();?>index.php/company/final_review?id=<?php echo $this->input->get('id'); ?>', type : 'POST', data : $("#dataform").serialize(), dataType:"json", beforeSend: function(){ $('#remarks').parsley( 'addConstraint', { minlength: 5 }); }, success : function(data){ console.log(data); } }); } This is my ajax part. The plugin is not validating the field it's submitting the form. The...

How to calculate values of a drop down menu with PHP/ JS?

Hi I have been very puzzled how to do this and cannot find any relevant tutorial that could help me so I thought I would ask here and hope to find the help. I have a form with 2 drop down menus, each of them having a value attribute. What...

json_encode and parsing information if there are no records returned

I make some AJAX (PHP + JQuery), but I have one problem. I have: dataType:"json", in Javascript Everything works fine when json_encode returning some records from DB. The problem is what to do, how to say server in case that there are not any records? When I have an array...

When is the cookie set by AJAX available in javascript?

I'm doing an AJAX call and setting a cookie in the user browser in the response (the server code sets the cookie). I noticed in the success callback from the ajax, the cookie is not available. When I look in document.cookie the new cookie is not there. My question, when...

How to send current page number in Ajax request

I am using jQuery DataTable to display huge amount of data in a table. I am getting data page wise on Ajax request like this: var pageNo = 1; $('#propertyTable').dataTable( { "processing": true, "serverSide": true, "ajax": "${contextPath}/admin/getNextPageData/"+pageNo+"/"+10, "columns": [ { "data": "propertyId" }, { "data": "propertyname" }, { "data": "propertyType"...

cross domain ajax form post — How is this allowed?

I am using jQuery and jQuery form plugin There is a method in jQuery form plugin ajaxSubmit. You pass a form and then it submits it via ajax and you get a response. I am wondering how this is possible since the form is on a different server than the...

Is there a way to fire an event every time an ajax call in made in AngularJS?

What I'm trying to do is every time a call to the backend is made, I want a spinner to load up with a dark overlay. I know I can do this by simply running the spinner before the call is made, but I'm working with multiple developers and I...

How to simulate $.ajax array POST request with Java

I'm trying to simulate ajax post request with java program. The simulation works but if I post an array, it comes back as a string. I'm using Guava: Map<String, String> data = new HashMap<String, String>(); data.put(URLEncoder.encode("affected_ids[]", "UTF-8"), URLEncoder.encode(Joiner.on(":").join(arrIds), "UTF-8")); data.put("select_all", "true"); String d = Joiner.on("&").withKeyValueSeparator("=").join(data); The content of d looks...

How to use ajax response JSON data?

I have made my ajax request, which works great and returns JSON. But how do i use it? My response is something like this [{ "id": "5", "reviewID": "2389", "serviceID": "50707", "title": "well done" }] Now in my success function I am trying to use the data like such: success:...

Check with jquery if result/echo from PHP starts with “abc”

I am using jquery and ajax to submit forms without page reloading and then depending on the result (whether it is a success or an error) I print the message in two different divs. Since success and error in ajax only checks the client/server connection I echo some stuff from...

Very weird behavior when using “var” keyword in an ajax request

I've been worrying about this for a while and I can't realize what's really happening. Explanation in code comments. There are 2 versions of an application, one of them throws weird results and the second one does the expected work. var id = "test1"; $.post("http://fiddle.jshell.net/echo/json/", {"data": "data"}, function(a) { alert(id);...

No Ajax success after php-script is run

I have a php-script which performs a database backup of my website. This backup-script can be triggered by clicking a button on the websites' admin-panel. I'd like to have some text in the admin-panel that tells the user when the backup is ongoing and when it's complete (process takes about...

Updating View in Angular js on ajax success callback

I am working on a project where I am getting list of the offers from a service. Each offer is Active or Inactive. I am displying only Active offers on a view on tabular format by giving ajax call and using ng-repeat. When I click on the link Inactivate Offer...

how to use geocoder class to retrieve latitude and longitude through ajax

the json array which contains the list of addresses [ { "id": 0, "title": "Coop.Sociale Prassi e Ricerca Onlus", "latitude": 0, "longitude": 0, "address": "Viale Eleonora D'Arborea 12, Roma, IT" }, { "id": 0, "title": "San Lorenzo", "latitude": 0, "longitude": 0, "address": "Viale della Primavera 330, Roma, IT" },...