Menu
  • HOME
  • TAGS

Javascript asynchronous calls to a function that updates DOM elements are overlapping and causing issues

javascript,jquery,html,ajax,forms

If the user types fast, then you can end up with multiple animations in process at the same time and the .hide() which is not an animation will go in the wrong sequence, potentially ending up with the wrong display. The animations queue in order, the .hide() does not so...

how to use .load(function() { on a large function

javascript,jquery,ajax,css3

You would want multiple deferred objects to pass them into $.when(). I believe you're looking for something like this: var d1 = new $.Deferred(); var d2 = new $.Deferred(); var d3 = new $.Deferred(); $.when(d1, d2, d3).then(function() { // perform your animations here }); $(img1).load(function() { d1.resolve(); } $(img2).load(function() {...

Array json between ajax and php

javascript,php,jquery,ajax,json

Make sure the JSON contains an array Add headers use getJSON Like this: PHP $data = array(); while ($row = mysql_fetch_assoc($result)) { $data[] = $row; } header("content-type: application/json"); echo json_encode($data); JS: $(function() { // when page has loaded var tId = setInterval(function() { // save the tId to allow...

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

javascript,php,jquery,ajax,button

You are binding your event handlers when the page opens / the DOM is ready, on $(document).ready(). Then you add new items using ajax but the links in these items will not have your event handlers bound to them. You can use event delegation to make sure that the events...

div replacing everything after it, AJAX, PHP, JAVASCRIPT

javascript,php,jquery,html,ajax

I testing your code in my pc and it worked. But after change this echo "<div id = 'output'>"; into this echo "<div id = 'output'></div>";, the output only show inside div block and everything after the div gets not replaced. If you want something similar to onload, just use...

How to create sub string in a line read from text file separated by comma

javascript,ajax,regex,file-handling

Use str.split() https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split So first we need to split on the newline \n character to get all of the lines. Then for each line, we split on the comma , character to get each of the three substrings, as you say. Here is a verbose but simple way to do...

UpdatePanel AsyncPostbackTrigger not firing

asp.net,ajax,webforms,updatepanel

I have just tested your code and seems to be working with some test modifications: ASPX <asp:UpdatePanel ID="UP_Panel" runat="server" UpdateMode="Conditional"> <ContentTemplate> <asp:DropDownList ID="ddlSwitch" runat="server" Width="250px" AutoPostback="true" OnSelectedIndexChanged="ddlSwitch_SelectedIndexChanged"> <asp:ListItem Value="continent" Text="Continent"></asp:ListItem> <asp:ListItem Value="region" Text="Region"></asp:ListItem> <asp:ListItem Value="country"...

get XML tags from URL using javascript

javascript,ajax,xml

Here is a basic example, it uses YQL to bypass CORS var pre = document.getElementById('out'), oReq = new XMLHttpRequest(), url = 'http://open.api.ebay.com/shopping?version=581&appid=EBAYU91VTR1SQ8H917BC11O3BW8U4J&action=getResults&callname=FindItemsAdvanced&QueryKeywords=Aston+Martin+V12+Vanquish&categoryId=220', yql = 'http://query.yahooapis.com/v1/public/yql?q=' + encodeURIComponent('select * from xml where url="' + url + '"') + '&format=xml&callback'; function updateProgress(oEvent) { if...

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

javascript,ajax,google-maps

Because of it's scope, your codeAddress javascript function is not visible for outer caller myLoop, as it is enclosed within myFunction, therefore you get the codeAddress is not defined. Try to rewrite your code similar to this (I have not tested, so it might not work right away, but you...

How to load two PHP scripts simultaneously using jQuery?

php,jquery,ajax

It sounds like your computer is not handling multiple connections. I have found a similar question on superuser.stackexchange - XAMPP apache not handling multiple requests His solution is: Starting and stopping the session every time I want to write to the session works though. Without him supplying any code, I...

Disable 2 buttons after click of a button

javascript,php,jquery,html,ajax

You can achieve this by disabling the buttons before you make the AJAX request, and then enabling them again in the complete handler of the request. Try this: var onSubmit = function(e) { var txtbox = $('#txt').val(); var hiddenTxt = $('#hidden').val(); $('.botleftbtn, .botrightbtn').prop('disabled', true); // < disable the buttons $.ajax({...

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

javascript,ajax,http,meteor,facebook-javascript-sdk

Don't pass a callback to get the HTTP to return. You're also able to pass off URL parameters quite easily: var result = HTTP.call("GET", "https://graph.facebook.com/me", { params: { access_token : Meteor.user().services.facebook.accessToken, fields : "likes.limit(5){events{picture,cover,place,name,attending_count}}" } }); console.log(result); ...

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

javascript,ajax,angularjs,express

In Angular this can be solved with an interceptor. See Angular-loading-bar as example.

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

ajax,knockout.js

You can use the subscribe method of an observable: vm.currentTab.subscribe(function(newValue) { //currentTab has just changed value, to newValue //You can fire your Ajax call here. }); ...

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

javascript,php,ajax

I am not sure by your question if you want to add it to the db on the selection... that would require a simple but different code. This will accomplish what you are asking. You do not need a form... just the selection boxes. If you notice I encased each...

Building an Ajax System for loading New Page Content via link classes

javascript,jquery,ajax,load

Assuming your scripts are loaded in your header, then you don't need to reload them with .getScript. That would just keep adding them into the page again for every link you click! Your main function looks mostly correct - although it seems to be missing the first line - but...

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

javascript,php,jquery,ajax

Your needs use enctype='multipart/form-data'. <form id="business-form" enctype='multipart/form-data'> </form> ...

.NET web service gets null object

c#,.net,ajax,web-services,rest

Possibly the mistake in this line var data = '{ "c:":{"Id": "1", "Name": "myname"}'; should be var data = '{ "c":{"Id": "1", "Name": "myname"}'; ...

jquery - add header request to specific ajax request

javascript,jquery,ajax

This is what you are looking for I believe. $( document ).ajaxSend(function( event, jqxhr, settings ) { if ( settings.url == "someURL" ) { jqxhr.setRequestHeader(key,value); } }); ...

laravel file uploading using json

jquery,ajax,json,laravel,laravel-5

Use this as your code: e.preventDefault(); var mydata = new FormData($('#my_form')[0]); $.ajax({ type: 'POST', cache: false, dataType: 'JSON', url: 'tasks', data: mydata, processData: false, contentType: flase success: function(data) { console.log(data); }, }); Note that this doesn't work on some older browsers such as IE 9 or older so you might...

Getting a JavaScript object into my controller: What am I missing here?

c#,asp.net,ajax,json,asp.net-mvc

The issue is with the way your JSON object is defined. It should have the single quotes for the prop names like this: {'org': 'string1', 'cat': 'string2', 'fileName': 'string3'} ...

How to access elements rendered into the page with Mustache using jQuery

javascript,jquery,ajax,mustache

Why not call componentLoaded() inside the success function? function renderComponent() { // Get Data return $.ajax('JSON/testData.json',{ dataType: 'json', success: function(data) { if(template != null) { for(var i = 0; i < data.blocks.length; i++) { renderTemplate(template, data.blocks[i], $('#container')); } componentLoaded(); } else { console.error('Error: Template failed to load'); } // or...

Automatically calling server side class without

javascript,html,ajax

Trigger the click event like this: $('._repLikeMore').trigger('click'); ...

AJAX request doesnt change text in div

javascript,jquery,ajax

Since you are performing an async request str will not be set until the ajax request is complete and success handler is invoked. Move param.html(str) inside the ajax success handler then it will update the text in the div. function updateChat(param) { var dataString = 'update=true'; var str = '';...

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

javascript,jquery,arrays,ajax

Here is my Solution var id = "1#2#3#4#5#"; var chkdId = id.slice(0, -1); console.log(chkdId); var arr = chkdId.split('#'); var checkedId = ''; var chkdLen = arr.length; // here is the array var arrayWithResults = []; for (var i = 0; i < chkdLen; i++) { checkedId = arr[i]; var checkedId...

Refresh table guestbook

php,jquery,html,ajax

You could use jQuery to check every few seconds if there is a new post (by using a get or ajax call). If there is a new post, you could append it to the table. That way the page won't have to refresh, and the person writing a post can...

static void c# webmethod can't reference user control?

c#,ajax,webmethod

I am getting the error that this is not valid in a static property. Indeed. In fact, in this case, it's a static method. A static member is one which is associated with the type, rather than with any instance of the type - so here, we could call...

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

javascript,ajax,variables,var

Cool, you discovered hoisting. MDN explains it as good as anyone: Because variable declarations (and declarations in general) are processed before any code is executed, declaring a variable anywhere in the code is equivalent to declaring it at the top. This also means that a variable can appear to be...

Ajax function not working when passing one of the variables through parameter, PHP, JAVASCRIPT, AJAX

javascript,php,jquery,ajax

You have omitted double quotes and concatenation here: data: { select: $('select[name="'+theName+'"]').val()}, ...

Making an alert() with PHP and ajax

javascript,php,jquery,ajax

You're trying to output javascript from the php, without outputting it in your ajax callback, won't work. The easiest way to do what you want, is to return the string with your php, and handle the outputting to your javascript. something like : if($QueueCount == 1){ Echo "You already have...

How to write .htaccess file for AJAX page

php,jquery,ajax,.htaccess

I think it's more related to apache than ajax. Anyway - your RewriteRule is ^findcontents/([A-Za-z0-9-]+)/?$ and you post to the url '/findcontents'. Did you try to post to '/findcontents/asdf' ? Another option is to add ^findcontents$ to your rules. If none of these works for you please provide some more...

Check AJAX response data before taking action

javascript,php,jquery,ajax

I would return a json string, with a flag for what type of content it is: if ($numLegs == 1) { echo json_encode(['type' => 'form', 'content' => $formData]); } else { echo json_encode(['type' => 'modal', 'content' => $modalContent]); } And then in your js: $.getJSON("ajax.php", { date: date, num: num...

Use a call Ajax to send an Array of string to mvc Controller

javascript,jquery,arrays,ajax,asp.net-mvc

You just need to change var t = $(this).html(); to var t = $(this).text();

Odd Contradictory Error

javascript,ajax

You are calling setTimeout(sndReq(), refreshDelay); which will execute sndReq() immediately because of the way you pass the function to setTimeout. Since your sndReq() is in your head, the HTML will not have fully loaded yet so you are receiving the selector error because the element doesn't exist (yet). You can...

WooCommerce seems to only orderby date and not price

php,ajax,wordpress,woocommerce

Try this: $args = array( 'post_type' => 'product', 'posts_per_page' => 100, 'product_cat' => 'beast-balls', 'orderby' => 'meta_value_num', 'meta_key' => '_price', 'order' => 'asc' ); ...

Yii reload page after CGridview Delete

php,ajax,yii

You can use afterDelete parameter (attribute) which exists in CButtonColumn class: 'class'=>'CButtonColumn', 'header'=>'Delete', 'template'=>'{delete}', 'afterDelete'=>'function(link,success,data){ if(success) { // if ajax call was successful !!! if(data == SUCCESS_TEXT) { // SUCCESS_TEXT the text which you output in your delete action on success window.location.reload(); } else { alert('Error! not deleted.'); } }...

How to increment number of fields in php using javascript or jquery or ajax without reload whole page

javascript,php,jquery,ajax,yii

You can do using ajax request but for multi text fields you need to write/array certificate_name[] instead of certificate_name. here is working & simple codes for you - Add More Button - <a class="btn btn-primary add-more" href="#">Add More</a> Add More Field JS Code - $('.add-more').live('click', function(){ var url_path = '';...

jQuery tab moves to last tab on button click

jquery,ajax,tabs

I would do slight mods to your current js and check whether it solves your prob: $("form[name='formAddProductGeneralInfo']").submit(function(e) { var currentli=$('.nav-tabs').find('li.active')//keep reference to your active li var currentContent=$('.tab-content').find('div.active');//reference to your current active content var inputData = new FormData($(this)[0]); $.ajax({ url: '{{ url('/admin/products/general') }}', type: 'POST', data: inputData, async: true, success: function(...

Why PartialView cannot reload with Ajax in MVC

ajax,asp.net-mvc,asp.net-ajax,asp.net-mvc-partialview,ajax.beginform

You need to do custom ajax post without HTML helper in this case. Create a normal form : <form id="frmEdit" class="form"> @Html.AntiForgeryToken() <div class="container"> @Html.ValidationSummary(true) //.... rest form component <button id="btnSubmit" type="submit">Submit</button> </div> </form> and do post by jquery similar like this <script> $( "form" ).on( "submit", function( event )...

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

php,jquery,ajax

Don't use string matching for this task. Use HTTP response codes - that's what they're there for! The http_response_code function in PHP is designed for this exact purpose: <?php if ( /* error condition */ ) { http_response_code(400); // "Bad request" response code echo 'Invalid parameters'; } else { echo...

How to send data from one form on a page with multiple forms through AJAX?

php,jquery,ajax

Here is the problem: data: $("form").serialize(), This code finds and serializes all form elements in DOM, not just the one you wanted. Quick fix: $(document).ready(function(){ $("form").submit(function(){ var str = $(this).serialize(); $.ajax({ type: "POST", url:"do.php", data: $(this).serialize(), // serialize only clicked form, not both }); return false; }); }); Note that...

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

c#,jquery,asp.net,ajax,json

Have a look at this answer MVC4 project - cannot have dot in parameter value? Try changing the Web.Config file <system.web> <httpRuntime relaxedUrlToFileSystemMapping="true" /> </system.web> ...

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

ajax,jsf,jsf-2,jsf-2.2,wildfly

This is a bug in Mojarra. I've just reported it as issue 3968. For now, one work around is to pass them as EL method arguments instead. <h:form enctype="multipart/form-data"> <h:commandButton value="Submit" action="#{bean.action(true)}"> <f:ajax execute="@this" render="@this"/> </h:commandButton> </h:form> public void action(boolean myparam) { // ... } ...

Server side vs client side website

javascript,html,ajax,html5,seo

There is only one real SEO issue at stake here: content accessibility. Some search engines don't execute Javascript as part of crawling and indexing. So if your content cannot be accessed with a URL defined in a sitemap without using Javascript, then such content will not be indexed and ranked....

nested ajax parent completed before child had finished

jquery,ajax,json,nested

I already post my answer in comments anyway I can think in 2 ways to try solving your issue: Add async: false, to your nested calls Try moving your div print out to the last (the second one) nested "success" call, but first verify all the calls are being executed...

Identifier starts immediately after numeric literal

jquery,ajax,razor

I think you have to include it with the ' mark Like this : var userID = '@User.Identity.GetUserId()';...

attempting to alter data via POST and ajax in django not working

jquery,ajax,django,post

You need this documentation from Django, I guess you are missing the CSRF Token in your POST data.

Updating View in Angular js on ajax success callback

ajax,angularjs

Your code correctly performs a GET request to inactivate the offer, however you do not "tell" Angular that the offer has been inactivated. What you need to do is remove the offer from the offers list $scope.offers once the offer is successfully inactivated (ie. when the inActivateOffer promise is resolved)....

How use jquery getJSON with a local variable

javascript,jquery,ajax,json,ace-editor

JSON is JavaScript Object Notation, so this: [] or {} is JSON. I guess you only need: getCompletions: function(editor, session, pos, prefix, callback) { if (prefix.length === 0) { callback(null, []); return; } callback(null, wordList.map(function(ea) { return {name: ea.word, value: ea.word, meta: "optional text"} })); } $.getJSON will call the...

Getting a collection via Ajax to show in view

jquery,ruby-on-rails,ajax

Your partial (currently named: _followup.html.erb in your example) should just be the code to produce a single row, Rails will iterate over it for you, and you should name it after the model it represents, ie. # app/views/assessments/_assessment.html.erb <%= assessment.name %> Then in your app/views/assessments/followups.html.erb view you'd use that partial...

Modal won't close on ajax success

jquery,ajax

You're using the wrong method to hide the element. Change this: $('#modal-container').modal('hide'); To this: $('#modal-container').hide(); Or if you want to completely remove it from the page, change it to this: $('#modal-container').remove(); ...

Unable to upload file to Sharepoint @ Office 365 via REST

javascript,ajax,rest,sharepoint,office365

To me it just seems a bit light, visit this link https://msdn.microsoft.com/en-us/library/office/dn769086.aspx on technet, and compare your upload function to this: // Add the file to the file collection in the Shared Documents folder. function addFileToFolder(arrayBuffer) { // Get the file name from the file input control on the page....

angular $http get all headers

ajax,angularjs

I don't know why and how angular produces the headers object, but the reason of this error is that the object has no hasOwnProperty() function, which is used by ng-repeat loop to avoid standard JS functions calls. What I managed to do is simple copying of the properties in a...

How can I properly test PHP scripts that have been POSTed to using AJAX?

php,ajax

As the method is POST, just echo the $_POST value: print_r($_POST); Or, like in your example, but instead of parse_str use extract: extract($_POST); echo $name; echo $company; echo $email; echo $phone; echo $message; echo $signUp; And in your ajax function change success to: success: function( msg ) { console.log(msg); }...

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

javascript,jquery,ajax,phantomjs,casperjs

I would do something like this in include.js: (function(){ window._allAjaxRequestsHaveStopped = false; var interval; $(document).ajaxStop(function() { if (interval) { clearInterval(interval); interval = null; } interval = setTimeout(function(){ window._allAjaxRequestsHaveStopped = true; }, 500); }); $(document).ajaxStart(function() { if (interval) { clearInterval(interval); interval = null; } }); })(); This sets a (hopefully unique)...

Using ajax to display what is being typed not working, PHP, AJAX, JAVASCRIPT

javascript,php,jquery,ajax

function ajax(url,unused,id) { $.post(url,{select: $('input[name="select"]').val()}) .error(function(e){ alert(e); }) .success(function(d){ $("#"+id).text(d); }); } ...

How to transform $.post to $.ajax?

javascript,jquery,ajax,json,servlets

$.post("../admin-login", { dataName:JSON.stringify({ username:uname, password:pass, }) }, function(data,status){ console.log("Data:"+data); answer = data; } ); becomes function getResult(data) { // do something with data // you can result = data here return data; } $.ajax({ url: "../admin-login", type: 'post', contentType: "application/x-www-form-urlencoded", data: { dataName:JSON.stringify({ username:uname, password:pass, }) }, success: function (data,...

No Ajax success after php-script is run

php,jquery,ajax

Your script db_backup.php should output something in JSON format, echo something like this. echo json_encode(array('success')); OR You can change your code to this: <button id="btn">Backup</button> <script> $("document").ready(function(){ $("#btn").click(function(){ $.ajax({ type: "POST", url: "backup/db_backup.php", success: function(data) { alert("success!!!"); } }); }); }); </script> ...

stop the video while close popup window

javascript,html,ajax

It looks like a typo : $(closevideobutton) doesn't point to anything. You may want to change var closevideobutton = '.hidevideo'; to var closevideobutton = '.btn-default, .close'; plunkr (I removed the ajax because of a problem with plunkr)...

post serialized data through using jquery load method in codeigniter

javascript,php,jquery,ajax,codeigniter

serialize method create a string output. to Make a POST call you need to use JSON object. $('#user').on('submit',function(event){ event.preventDefault(); var data=formToJSON('#user'); adddetails(data); }); function adddetails(data){ var url='http://localhost/projectname/index.php/users/adddat'; $("#output").load(url,data,function(response,status){ }); } function formToJSON( selector ) { var form = {}; $(selector).find(':input[name]:enabled').each( function() { var self = $(this); var name = self.attr('name');...

access the json encoded object returned by php in jquery

php,jquery,ajax,json

Try: $.ajax({ url: "functions.php", dataType: "JSON", data: {id: id}, type: 'POST', success: function(json){ for(var i=0;i<json.length;i++){ alert(json[i].fname); } } }); ...

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

javascript,jquery,ajax,datatables

Use the code below instead: table.row.add({ "college_abbrev": ca, "college_name": cn, "college_id": college_id }).draw(); You're getting "Requested unknown parameter" error because you're passing array of objects to row.add(), where you should pass simple object instead, see row.add() for more information. Also you don't need to construct a button in a call...

Strange situation, Visual Studio debugging ran through action to view but nothing returned to browser

c#,jquery,ajax,asp.net-mvc,razor

error: function () { alert("EmptyResult returns."); debugger; $.post('@Url.Action("Delete2", "Customers")', { id: clickedId }); }, Result of a post does not refresh your page, so quick fix is to genrate an anchor with URL to controller action add id parameter and click on it or change window location with controller/action/clicked id....

How to simulate $.ajax array POST request with Java

java,javascript,php,ajax

If you want PHP to automatically recognize the data as array, you have to sent multiple parameters with the same name, each ending in []. For example: foo[]=1&foo[]=2 will be accessible in PHP as $_GET['foo'], returning the array array(1,2). More information can be found in Variables From External Sources and...

Ajax PHP file upload mistake

php,ajax,multipartform-data

You can use this code for file uploading with ajax in pure javascript. Change this "#fileUploader" according to file field ID. var AjaxFileUploader = function () { this._file = null; var self = this; this.uploadFile = function (uploadUrl, file) { var xhr = new XMLHttpRequest(); xhr.onprogress = function (e) {...

How to send current page number in Ajax request

javascript,jquery,ajax,spring-mvc,datatables

DataTables already sends parameters start and length in the request that you can use to calculate page number, see Server-side processing. If you still need to have the URL structure with the page number, you can use the code below: "ajax": { "data": function(){ var info = $('#propertyTable').DataTable().page.info(); $('#propertyTable').DataTable().ajax.url( "${contextPath}/admin/getNextPageData/"+(info.page...

When is the cookie set by AJAX available in javascript?

javascript,ajax,cookies

Cookies are passed as HTTP headers, both in the request and in the response. When you do an ajax call and set a cookie, that cookie will only be available in the browser after a reload / redirect happens, and new headers are gotten from the server containing the newly...

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

javascript,jquery,ajax,wordpress,forms

Dont use one(it will fire ajax submit or button click only once) , use here var IsBusy to check user is not repeatedly pressing the form submit, Try below code, var isBusy = false; //first time, busy state is false $('#publish').on('click', function (e) { if(isBusy == true) return ; //if...

Loading external php file in a div with jquery ajax

javascript,php,jquery,ajax,mysqli

You have to add jquery js in your html code. you can use online jquery. <script src="//code.jquery.com/jquery-1.11.3.min.js"></script> <script src="//code.jquery.com/jquery-migrate-1.2.1.min.js"></script> ...

ajax test not working

javascript,php,jquery,ajax

I want the php file to pass the $add1 to the Javascript and then i want the javascript to return the var sum back to the php and the php to echo the $sum from the $POST. $sum from $_POST is actually echoed, but not shown in HTML page,...

Sending LIst via ajax to complex model

javascript,c#,asp.net,ajax

You don't need to JSON.stringify the recipients. "recipients": JSON.stringify("[{'firstname':'a','lastname':'b','email':'c','voucheramount':'d'}]") Remove JSON.stringify form here and it should work. var postData = { "workplaceGiverId": $(".wpgDropdownList").val(), "fromMemberId": $(".wpgFromMemberDropdownList").val(), "toMemberId": $(".wpgToMemberDropdownList").val(), "voucherExpiryDate": $("#expiryDatePicker").val(), "recipients": [{'firstname':'a','lastname':'b','email':'c','voucheramount':'d'}] }; ...

How to use ajax response JSON data?

javascript,jquery,ajax,json

As data is array of objects, use data[0].title: $('#myModalLabel').text('Review:' + data[0].title); // ^^^ ...

Event on blur and on submit?

javascript,jquery,ajax

Change your function to a named function expression, then re-use the definition, like this: var submitFunction = function(event) { // stuff } $('input[type=text]').on('blur', submitFunction); $('input[type=submit]').on('click', submitFunction); Also, you don't need the middle argument to on() - you can just use the $ function to target the elements you want. This...

Uncaught ReferenceError: is not defined onclick when using character strings

javascript,jquery,ajax,onclick

You need to wrap the input item.store_code with quotation marks; otherwise, it tries to treat it as a variable, not a string: html += '<div class="col-sm-3"><input type="button" onclick="noActivationCodeRegistration(\'' + item.store_code + '\');" value="This Is My Store" data-store-code="' + item.store_code + '"></div>'; Ideally, you would attach a click handler after giving...

Why are fields reset after ajax update with Primefaces

ajax,jsf-2,primefaces

Why are fields reset after ajax update with Primefaces This problem has 2 possible causes depending on the concrete functional requirement: It's because you didn't tell JSF to process the desired input values. Or, it's because you told JSF to also update the non-desired input values. The solution depends...

Symfony2: ajax call redirection if session timedout

ajax,symfony2,session

Found a working solution : Add a function in my global controller which check if session is still active and responds with "ok" if yes, "ko" if not. public function pingAction() { $securityContext = $this->container->get('security.context'); if ($securityContext->isGranted('IS_AUTHENTICATED_REMEMBERED') || $securityContext->isGranted('IS_AUTHENTICATED_FULLY')) { return new Response("ok"); } return new Response("ko"); } and i...

JQuery Operator Got Wrong Value

javascript,php,jquery,ajax

JavaScript's parseInt and parseFloat stop at the first invalid character, and they don't support commas, so parseInt("180,000") returns 180. To parse your numbers, you'll need to remove the commas: var hargaProduk = parseInt($("#harga_"+fuid).text().replace(/,/g, "")); // ------------------------------------------------^^^^^^^^^^^^^^^^^^ ...and then add them back when displaying; if you search, you'll find solutions for...

asp.net get user information from xmlhttp requests

asp.net,ajax,forms-authentication

HttpContext.Current.User returns an object of type IPrincipal, and IPrincipal.Identity returns an object of type IIdentity. HttpContext.Current.User.Identity.Name gives you the username HttpContext.Current.User.Identity.IsAuthenticated gives you the authentication status (boolean) Armed with that, you can look up other details in the database, possibly storing them in the Session....

jQuery or AngularJS Ajax “POST” request to server using code below however do not sending param data to server.

javascript,jquery,ajax,angularjs,iis

Without seeing your server-side code it is difficult to say if that is a problem. The JS you have presented generally looks okay. You say that it runs without errors but fails to produce the expected results on the server. So I suggest you add the server-side code. Both cases...

Hide 'show more' button using AJAX

javascript,php,jquery,ajax,wordpress

Check this functions.php function buttonHide() { $posts_count = wp_count_posts()->publish; if ($posts_count <= 2) { $result['type'] = "success"; $result['status'] = 'hide' ; $result = json_encode($result); echo $result; die(); }else{ $result['type'] = "success"; $result['status'] = 'show' ; $result = json_encode($result); echo $result; die(); } die(); } add_action('wp_ajax_buttonHide', 'buttonHide'); add_action('wp_ajax_nopriv_buttonHide', 'buttonHide'); add_action( 'init',...

Table goes max height when screen is resized

javascript,html,css,ajax,table

Tables have a built in property of "stretch to fit". Try putting the table in a div with the same max/min height and overflow properties....

File not Uploading using Ajax in cakephp

php,jquery,ajax,file,cakephp

With this AJAX form submission approach, you will not be able to upload file using ajax. If you don't like using a third-party plugin like dropzone.js or Jquery file upload, you can use XMLHttpRequest. An example below: $('#newcatform').on('submit', function(ev){ ev.preventDefault(); var forms = document.querySelector('form#newcatform'); var request = new XMLHttpRequest(); var...

Using ajax to display what is being selected not working, PHP, AJAX, JAVASCRIPT

javascript,php,jquery,ajax

you have not post data to test2!! <?php include('ajax.php'); echo "<select id = 'select' onchange = 'ajax(\"test2.php\",\"output\")'>"; echo "<option value = '1'> 1 </option>"; echo "<option value = '2'> 2 </option>"; echo "<option value = '3'> 3 </option>"; echo "</select>"; echo "<div id = 'output'/>"; ?> function ajax(url,id) { $.ajax({...

ajax post truncating leading zero's

javascript,jquery,ajax

When sending json to a server, you should use the built-in JSON.stringify method to create json rather than creating it manually. $.ajax({ type: "Post", url: 'http://example.com/jambo', contentType: "application/json", data: JSON.stringify($('InputTextBox').val()), success: function (data) { alert("success"); }, error: function (msg) { var errmsg = JSON.stringify(msg); alert("message: " + errmsg); } });...

Sending input data to a javascript file

javascript,jquery,ajax,html5,send

You can "send" the input field value to main.js by passing the input field value as a parameter to a function in main.js. main.js: function mainjsfunction(inputFieldValue) { console.log(inputFieldValue); //do something with input field value } html: <form> <input class="inputField" type="text" required="required" pattern="[a-zA-Z]+" /> <input class="myButton" type="submit" value="Submit" /> </form> <script...

What factors should take into consideration when choosing between basic AJAX (like HTTP polling) and reverse AJAX (like Long Polling)? [closed]

java,javascript,ajax,reverse-ajax

I think generally there can be 3 use cases: You want to display every single update to the user as soon as possible. If so, definitely go with Long Polling. Example: a chat. You don't need real time notifications and big delays are not a problem. In this case, Traditional...

Load multiple OBJ-files together with multple textures

ajax,three.js,textures

You can use anonymus functions. For example: loader.load(str_model_url, (function (url,scale) { return function (object, i) { console.log( url ); console.log( scale ); }}) (str_model_url, 0.5) , onProgress , onError ); ...

json_decode returns NULL, json_last_error throws 0

php,ajax,json

If you're posting data directly to PHP, you'll have to use php://input and parse that; data given in JSON isn't form data, and wont auto-populate the request superglobals ($_GET, $_POST). $data = json_decode(file_get_contents("php://input")); Most frameworks do this transparently for you and populate a request object with data in it. You...

json_encode and parsing information if there are no records returned

php,ajax,json

Here are two (of several) possibilities: PHP Option: Handle the NULL object to make it parseble ahead of time... if ($mydata==NULL) { $mydata = new stdClass(); } echo json_decode($mydata); JS Option: Try catching the error when parsing it on the client side. // Catch the error try { var data...

Jquery parsley validate not working

javascript,php,jquery,ajax,parsley.js

Make sure this line: $('#remarks').parsley( 'addConstraint', { minlength: 5 }); is called before you check isValid()....

cross domain ajax form post — How is this allowed?

jquery,ajax

If the server has a response header of 'Access-Control-Allow-Origin': '*' or something similar, it will return a response. In short, this has nothing to do with jQuery, and has everything to do with the server. In the case above, * is a wildcard representing all origins. But it could also...

Getting 302 response headers from Ajax.BeginForm?

c#,jquery,asp.net,ajax,asp.net-mvc

There is no way to make JavaScript AJAX queries to not follow redirects. (See How to prevent ajax requests to follow redirects using jQuery for more discussion). You should consider other options - i.e. returning JSON with "redirect location" would be more AJAX-friendly. return new JsonResult { JsonRequestBehavior = JsonRequestBehavior.AllowGet,...

create jquery array for ajax post

javascript,jquery,ajax,datepicker

Update Note on JSON. The default encoding will be url form encoded. If you want the request to send the data as JSON, you will need to add.. content-type: "application/json; charset=utf-8", also if you are returning JSON, you should add ... datatype : "json", Not sure which scripting language your...

Jquery html page dynamic control and load

jquery,html,ajax

The options added to the virtual select is not reflected. Either you can write the tr to DOM and then try binding the values OR return the updated data. http://jsfiddle.net/mn5b0hjg/2/ var bindDrpValues = function (control, valueList, setting) { for (var i = 0; i < valueList.length; i++) { var option...

Get all images from local folder

javascript,jquery,ajax

I think your best option is to use the new File API in Javascript. Is has a lot of functions to read files from the file system. <input type="file" id="fileinput" multiple /> <script type="text/javascript"> function readMultipleFiles(evt) { //Retrieve all the files from the FileList object var files = evt.target.files; if...

Multiple AJAX forms with the same ID on the same page

javascript,php,jquery,ajax,forms

Don't use the same ID for the top and bottom forms. An id must be unique in a document -- see MDN Docs. Instead have two separate id's and reference them both in the one jQuery call when you are binding to the submit event: $('#newsletter_top, #newsletter_bottom').on('submit', function(e) { //...