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


Trouble dynamically changing state of checkbox with AJAX

Question:

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?

$.ajax({
    type:"POST",
    url:"../scripts/domainlist.php?dept="+deptid+"&pro="+proid,
    contentType:"application/json; charset:utf-8",
    dataType:"json",
    success: function(data){
        $('#domainlist').empty();
        $('#domainlist')
        .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>
                 </tr>");
        var index = 0;
        $.each(data,function(i,item){

            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";
            }

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

enter image description here


Answer:

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


Related:


Disable 2 buttons after click of a button


javascript,php,jquery,html,ajax
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...

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


php,jquery,ajax
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...

How to load two PHP scripts simultaneously using jQuery?


php,jquery,ajax
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...

ajax test not working


javascript,php,jquery,ajax
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...

WooCommerce seems to only orderby date and not price


php,ajax,wordpress,woocommerce
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">...

How to use ajax response JSON data?


javascript,jquery,ajax,json
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:...

Sending LIst via ajax to complex model


javascript,c#,asp.net,ajax
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:...

No Ajax success after php-script is run


php,jquery,ajax
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...

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


javascript,php,jquery,ajax,button
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...

Unable to upload file to Sharepoint @ Office 365 via REST


javascript,ajax,rest,sharepoint,office365
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...

Multiple AJAX forms with the same ID on the same page


javascript,php,jquery,ajax,forms
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...

How to simulate $.ajax array POST request with Java


java,javascript,php,ajax
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...

json_encode and parsing information if there are no records returned


php,ajax,json
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...

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


javascript,jquery,ajax,phantomjs,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...

jquery - add header request to specific ajax request


javascript,jquery,ajax
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...

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


javascript,ajax,variables,var
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);...

Updating View in Angular js on ajax success callback


ajax,angularjs
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...

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


javascript,jquery,ajax,wordpress,forms
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....

How use jquery getJSON with a local variable


javascript,jquery,ajax,json,ace-editor
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) {...

Identifier starts immediately after numeric literal


jquery,ajax,razor
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....

Making an alert() with PHP and ajax


javascript,php,jquery,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...

Loading external php file in a div with jquery ajax


javascript,php,jquery,ajax,mysqli
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...

How to add checkbox to uicollectionview in swift


swift,checkbox,uicollectionviewcell
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...

Modal won't close on ajax success


jquery,ajax
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...

Automatically calling server side class without


javascript,html,ajax
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"> ...

Getting a collection via Ajax to show in view


jquery,ruby-on-rails,ajax
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",...

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


html,css,asp.net,checkbox
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;...

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


javascript,ajax,angularjs,express
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 return value in Meteor.JS from HTTP.call “GET”


javascript,ajax,http,meteor,facebook-javascript-sdk
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...

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


javascript,jquery,ajax,datatables
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":...

Get all images from local folder


javascript,jquery,ajax
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...

checkbox updating another checkbox on different form


javascript,checkbox
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()"...

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


javascript,php,jquery,ajax
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"...

Check AJAX response data before taking action


javascript,php,jquery,ajax
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,...

access the json encoded object returned by php in jquery


php,jquery,ajax,json
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",...

When is the cookie set by AJAX available in javascript?


javascript,ajax,cookies
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...

cross domain ajax form post — How is this allowed?


jquery,ajax
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...

Load page and input values


javascript,checkbox
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...

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


ajax,knockout.js
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 send current page number in Ajax request


javascript,jquery,ajax,spring-mvc,datatables
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"...

How to transform $.post to $.ajax?


javascript,jquery,ajax,json,servlets
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...

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


ajax,jsf,jsf-2,jsf-2.2,wildfly
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...

Jquery parsley validate not working


javascript,php,jquery,ajax,parsley.js
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...

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


c#,jquery,asp.net,ajax,json
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()...

How to write .htaccess file for AJAX page


php,jquery,ajax,.htaccess
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...

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


javascript,ajax,google-maps
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" },...

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


javascript,jquery,arrays,ajax
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...

Jquery html page dynamic control and load


jquery,html,ajax
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...

Why are fields reset after ajax update with Primefaces


ajax,jsf-2,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 calculate values of a drop down menu with PHP/ JS?


javascript,php,ajax
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...