w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Jquery bind on 'ajax:success', 'ajax:error' or 'ajax:complete' not executed even though form is submitted
In Jquery, Ajax Event has two types. One is local event, another is global event. Local Event, It will be defined with ajax request: $.ajax('YOUR PATH', {success: function(){ alert(!) }}); Global Event, It should be binded with document element: $(document).bind('ajaxSuccess', function() { alert('!'); }); see fiddle and jquery api

Categories : Jquery

Wordpress: Update jQuery variable using PHP on Ajax call
Ok, so I finaly figured it out, and I was looking very wrong at how to do it. This is for use with jPlayer if others are looking for a similar solution. Turns out I should use an ajax call to get the new information. I edited a lot of stuff, but this is how it ended up looking, if someone can use it for future reference. I should note that I use the title attribute of the clicked div to get information about what album the track is on. In the functions.php I wrote the following: function add_my_ajax_playlist() { wp_enqueue_script( 'my-ajax-playlist.js', get_bloginfo( 'template_directory' ) . "/js/my-ajax-playlist.js", array( 'jquery' ) ); } add_action( 'wp_enqueue_scripts', 'add_my_ajax_playlist' ); function behave_ajax() { // The $_REQUEST contains all the data sent via aja

Categories : PHP

jQuery Ajax:- How to remove pending ajax call and active recent ajax call?
You can do like this. var CurrentAjaxReq = null; if(CurrentAjaxReq != null) { CurrentAjaxReq.abort(); } CurrentAjaxReq = jQuery.ajax({url: '/xyz.php', success: function(data) { CurrentAjaxReq = null; //do something } });

Categories : Ajax

How to prevent page navigation until ajax call is complete
Pretty sure you can create a global in the .js file like... var request; Then assign your ajax call to this variable. request = $.ajax{ //Ajax //Stuff //Goes //Here } Now inside your window.unbeforeunload function, add this conditional statement. window.onbeforeunload = function(){ if(!request){ return "Request not initiated"; }else{ //Request is in progress... //You can use request.abort() if you need } } EDIT: To elaborate on on some of the methods you can use on the request object, check out this page. (for example, .done or .always may suit your circumstances)

Categories : Ajax

Call PHP Script from Auto-complete AJAX JQuery Mobile
You need to prepare a json object to send from your PHP file. Take a look at json_encode(). Ideally, you would prepare an associative array and then convert it to a JSON For example $arr = array(); $arr['name'] = 'PHP'; echo json_encode($arr); Output { 'name' : 'PHP' } You can then refer to the name in your JS as .then(function(resp) { console.log(resp.name); } This will output PHP in the console. However, you might be better off using jQuery UI's built in Autocomplete. Please refer to this post. Moreover, your code is vulnerable to SQL injections. You should switch to Prepared Statements to avoid this. UPDATE : As for your second issue, you can first assign a class to the list items, eg <li class="autocomp-data"> and then bind a click handler to it. $ul.html( ht

Categories : PHP

Show ajax spinner, hide page render until ALL ajax calls complete?
One approach would be to display your loading animation as part of your initial page & page load. Then, wait for your outstanding ajax calls to reach zero and once that happens, hide the loading animation. Your document ready would look something like: $(document).ready(function() { $('#spinner').addClass('spin'); function stopSpinner() { $('#loading').addClass('hide'); $('#loading').one('webkitTransitionEnd', function() { $('#loading').hide(); }); } $(document).ajaxStop(function () { // $.active == 0 stopSpinner(); }); }); Your markup would have something like this as the last elements in the body: <div id="loading"> <div id="spinner"></div> </div> With styles like this: #lo

Categories : Ajax

How to use ajax and update img src and call php function?
you don't need ajax at all: (unless you don't want to store your data to a database or a file): I hope this helps: http://jsfiddle.net/teeEx/ HTML: <a href="javascript:;" id="check1"><span class="checked">&nbsp;</span></a> <a href="javascript:;" id="check2"><span class="unchecked">&nbsp;</span></a> <a href="javascript:;" id="check3"><span class="unchecked">&nbsp;</span></a> <div id="result"></div> CSS: a{ text-decoration: none; } span{ display: block; width: 30px; height: 30px; margin: 20px; } span.checked{ background: green; } span.unchecked{ background: black; } JS: $('a').click(function(){ var a_obj = $(this); var obj = a_obj.children('span');

Categories : PHP

PHP Update MySQL DB with AJAX call isn't doing anything
There is something confusing here. You have a loop and after loop conditionals. Shouldnt your update query be inside a loop like: while($row = mysqli_fetch_array($checkit)) { $itStatus = $row["it"]; if($itStatus == "not it") { mysqli_query("UPDATE login SET it = CASE WHEN uname = '$youruname' THEN 'not it' ELSE 'it' END WHERE uname IN ('$youruname', '$selPlayerUname')"); $flag = "success"; } else if($itStatus == "it") { $flag = "nope"; } else { $flag = "error"; } } Your $iStatus gets the last value from the database since its in the loop and then you check in conditionals If above does not help then check your $_POST values to see if any of them are blank or null and do the query on PHPMyAdmin see if it actually re

Categories : PHP

Jquery Ajax call in asp.net Progress Bar update
try this: async:false, add to ajax call $(document).ready(function(){ GetValue(); var l_count= parseInt($("#txtcount").val()); $("#sliderlicense").progressbar({ max: 100, value: l_count }); }); }) function GetValue() { $.ajax({ type: "POST", url: "MyPage.aspx/GetCount", //url to point your webmethod contentType: "application/json; charset=utf-8", dataType: "json", async:false, success: function (Result) { $("#txtcount").val(Result.d); }, error: function () { alert('error'); } }); }

Categories : C#

update the model by an Ajax call - Spring mvc
You should be returning the data you want as the @ResponseBody or a ResponseEntity rather than adding it to a Model. Jackson (or whatever) should serialize it automatically to JSON so that it can be consumed in your success/done callback on the front end. AJAX requests are effectively service endpoints rather than MVC flows.

Categories : Jquery

Jquery Masonry update DIV after Ajax call
You need to tell masonry you are deleting it: $container.masonry( 'remove', elements ); http://masonry.desandro.com/methods.html#remove You also need to call $container.masonry() again after the remove to relayout everything

Categories : Jquery

Ajax call (b) within callback of another ajax call (a) executes before (a) completes
You are executing ajaxB here: ajaxB(1) I think what you want to do is either return a function from ajaxB or find a way to pass the isPublic flag to your ajaxA function like: ajaxA(ajaxB, 1); function ajaxA(callback, isPublic){ FB.api('/me', function(response) { //ajax call(a) ajaxAdata = response.id; callback(isPublic); // this completes before ajax call(a) completes } }

Categories : Javascript

jQuery-How to call multiple ajax calls in one ajax call
Not possible in most cases Each ajax call involves the browser sending information to a server at a particular URL. If you reduced the browser code from two ajax calls to one ajax call, the server would receive less information, the browser would not receive some information it is getting now, and/or the server would perform fewer operations. If you control the server code, you might be able to change the server code to be able to do both operations in one step. Only then could you change the browser code.

Categories : Jquery

How to replace div's content by partial view or update it's content depending on what json result returns on ajax complete?
I had to solve this problem once so very long ago. I came up with a simple solution, which today, may not be the best solution but it gets the job done. My solution involved setting up a controller action that would render just the partial with data that it would need and have my JavaScript request it. C# MyController: Controller { public ActionResult GetPartialViewAction() { return PartialView("mypartialview", new partialViewModel()); } } JavaScript $.ajax({ url: "/my/getpartialaction/" }).done(function() { $("#partialViewDiv").html(data); }); HTML <div id="partialViewDiv"></div> A better solution would be to use a MVVM/MVC JavaScript library that would allow you to leverage html templates and only have to transmit the data over your ajax solution. I

Categories : C#

Javascript variable does not update via ajax
AJAX is asynchronous, so at time you try to read value of variable outside the ajax callback functions, it's still undefined. So code your logic using variable value inside the callback function, here success callback. You could use a defered object too. Please read that: How to return the response from an AJAX call?

Categories : Javascript

Scope variable in ajax call
Change async to the boolean false. http://api.jquery.com/jQuery.ajax/ var time; $.ajax({ async: false, type: 'GET', url: "http://www.timeapi.org/utc/now.json", success: function (data) { console.log(data); time = data; }, error: function (data) { console.log("ko"); } }); console.log(time); Also, note that if you need to use dataType: 'jsonp' here for cross-domain, you won't be able to synchronize -- so use a promise. var time; $.ajax({ dataType: 'jsonp', type: 'GET', url: "http://www.timeapi.org/utc/now.json", success: function (data) { time = data; }, error: function (data) { console.log("ko"); } }) .then(function(){ // use a promise to make sure we synchronize off the jsonp console.

Categories : Javascript

Knockout observable binding only update after first ajax call
Initializing stuff should be safe there. I also use the activate hook and return a promise in there. Not sure which one is the prefered event. The root problem i guess is because of the lack of a promise from your Ajax call. Try changing so or at least use $.Ajax with async: false.

Categories : Javascript

ajax API call Variable {variable} - How do I change it
You need to build up the URL dynamically, based on each account parameter. You could use a small reusable function for that: function createEvent(account, eventData, callback) { var url = "/events/" + account + "/events"; $.ajax({ type: "POST", url: url, data: eventData }).done(callback); } Then, to use it: var event = { name: "Marcus", location: "HERE" }; // Get some_account_number from somewhere... createEvent(some_account_number, event, function(msg) { alert( "CREATE EVENT Data Saved: " + msg ); });

Categories : Javascript

Append a variable from within an AJAX success call
You have to use proper quoting. $('#success') .append('<h2>Thanks '+data['name']+'!</h2><p>We will be in touch shortly</p>'); Notice that in your code you're opening your string with ' but closing it with "

Categories : Javascript

Diffence between usage of Ajax Update Panel and Jquery:ajax() method
An update panel performs a full re-render of the page, takes the section matching the panel and sends it back to the client. The browser then replaces the contents of the update panel with the new html. jQuery's AJAX method allows you to make any request to any page and handle the response data any way you choose. This might include reading a JSON response from a web service, getting html or anything else you wish. Effectively AJAX gives you a mechanism to emulate the user browsing to a given url with GET or POST data and manipulate the results in any way you desire. It's worth noting that the update panel is built on top of AJAX (technically Javascript's XMLHttpRequest) object. There are also some gotchas with update panel, eg if you have a Captcha that is outside the panel; When the

Categories : Asp Net

Rails - RSpec/Capybara and AJAX: How to test an AJAX database update?
You're going to need to use a Capybara driver that can run Javascript, like PhantomJS. The standard Capybara driver doesn't run Javascript, and thus wouldn't invoke click handlers or AJAX.

Categories : Ruby On Rails

only one ajax call from javascript loop instead of looping multiple ajax calls
JS-Call: $.post('update_page_positions.php', {'myArray': m}, function(data, statusText) { // This block is optional, fires when the ajax call is complete } ); AJAX-Handler: <?php include("connect.php"); $myArray = json_decode($_POST['myArray']); // do stuff with $myArray here. ?>

Categories : PHP

Real time update for voting system with an ajax call
You can give $.ajax a success callback that updates with something like: $.ajax({... success: function(data) {$('#element').val(data)}}) This will update the vote count right after casting the vote. However, if you want the vote to update without any user interaction, you can do some kind of polling or publish/subscribe.

Categories : Javascript

Unable to retrieve value in AJAX POST call. [Used AJAX, MVC ASP.net, .net framework 4.0]
you need to spe4cify the content type as JSON $.ajax({ type: "POST", url: $("#urlprefix").val() + 'AssetManagement/SaveNew', data: JSON.stringify({ del: del }), contentType: 'application/json', success: function (d) { console.log('here'); return false; }, error: function (msg) { } });

Categories : C#

How to get a part of HTML webpage in a jQuery ajax Request? In other words how to filter the web page contents on an ajax call?
success:function(data) { var out = ""; $(data).find("your selectors").each(function(loop, item){ out += $(item).html(); }); data = out; alert(data); $("body").html(data); }

Categories : Javascript

how to change type ajax call to controller of option "serviceUrl" in ajax autocomplete jquery devbridge with CodeIgniter?
I fixed my problems, but data that contains values for callback function when data is selected always null. What's up? MY SCRIPT: var options, a; $(document).ready(function(){ options = { serviceUrl:'controller_name/function_test', onSelect: function(suggestion) { alert('You selected ' + suggestion.value + ', ' + suggestion.data); } }; a = $('#search_by_user').autocomplete(options); }); MY FUNCTION IN CONTROLLER : public function function_test() { $query = isset($_GET['query']) ? $_GET['query'] : FALSE; //$query = 'te'; if($query) { $found = $this->model_name->get_list($query); $suggestions = array(); $data = array(); foreach($found as $row) {

Categories : Codeigniter

Update a PHP variable on the fly with ajax based on user input
set $base = $_GET['base'],and your url like this: test.php?base=400 it will work well. another way is to build a form ,which has a that let you input $base ,either by post or by get,then you can ues $base. hope these help you~~ <?php $base = $_GET['base']; //the width $altezza = 300; //the height (no need for calculation) $larg_fasce = 60; //the size of each piece (always 60cm) $num_fasce = floor($base/$larg_fasce); //calc the numbers of piece needed to cover the $base $dim_fasce = floor($base/$num_fasce); //calc the size of each piece $resto = $base-($num_fasce*$larg_fasce); //calc the rest to cover the $base ///////////// echo "Base: ".$base."<br>"; echo "Altezza: ".$altezza."<br>"; echo "Largh Fasce: ".$larg_fasce."<br><br>"; echo "Verranno fornite

Categories : Ajax

Call the ajax function again after Complete function
Try not to call load_pages() on complete because it causes a Recursive function which can make you run out of memory. Instead, call your function out of the $.ajax and then by binding the event click, like this. $(document).on("click","#portfolio_categories_list li > a",function(e){ e.preventDefault(); alert("test"); $categoria = $(this).attr("title").split("Ver todos os posts arquivados em "); load_pages("categoria"+$categoria[1]); });

Categories : Javascript

Ajax username and date Instagram API
The data parameter of the success handler function is populated from whatever JSON ajax.php returns and the structure will match accordingly. It looks like the images attribute of that object only has an array of URLs for the images and no other data. You'll need to update this section of the PHP script to return more than just the array of URLs for the images and also include the additional data retrieved from the Instagram API. Try updating the last part to this: echo json_encode(array( 'next_id' => $media->pagination->next_max_id, 'images' => $media->data )); Then you'll have full access to all the media data, not just the URL.

Categories : Ajax

callback function and global variable in jquery ajax call
Your alert after the $.ajax() instruction is executed AFTER the xmlhttprequest has started but BEFORE it has ended, i.e. before the success function is called. Thus at that time, globalVar is still undefined.

Categories : Jquery

Why does moving the console.log() for a variable into a second AJAX call change the output?
This is because you have a for loop where you assign value to your variables and start an ajax call, which will get executed before your ajax success callback executes. So they will hold the value of that last iteration. for (var i=0;i < results.data.length; i++) { var object = results.data[i]; if (object.canonical_name && object.name) { var productTitle = object.name; productURL = "getsatisfaction.com/trinet/products/" + object.canonical_name; jQuery.ajax({ type: 'GET', url: apiBaseURL + 'topics.json?product=' + object.canonical_name, dataType: 'jsonp', success: function(results2) { var numProductTopics = results2.total; console.log(productTitle); //<-- this will have the value from last iteration

Categories : Javascript

Assigning variable from jquery ajax call returns undefined
This is a very common problem for people not used to using asynchronous operations. It requires you to rethink how you structure your code because you can't just program in normal sequential style. You cannot return a value from the success handler of an asynchronous ajax call. The ajax cll has long since completed and already returned. Returning a value from the success handler just goes into the bowels of the ajax code, not back into your code. Instead, you must use the results of the ajax call in the success handler or in a function you call from the success handler. In your specific case, your getAverageRating() function probably needs to take a callback function and when the rating has been retrieved, the callback function will be called. It cannot return the value because it r

Categories : Jquery

How to send a Javascript/Ajax variable to a php page using AJAX
if you want to pass the ip as a GET value you have to add the GET key function runGetIperfSpeedAjax(speedVar, actualIp) { var xmlhttp = getAjaxObject(); xmlhttp.onreadystatechange = function () { if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { processIperfRequest(xmlhttp.responseText, speedVar); } } xmlhttp.open('GET', 'lib/getIperfSpeed.php?ip='+actualIp, true); // missing in your code '&ip='+actualIp xmlhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); xmlhttp.send(); } function processIperfRequest(response, speedVar) { alert("proccess"); document.getElementById(speedVar).style.display = 'none'; document.getElementById('displaySpeedTest').style.display = 'block'; docume

Categories : PHP

Update data fetched by ajax through ajax
Make sure you have your php.ini file configured correctly to send email. It could be an issue with the mail server you're using . Reconfigure to use something like gmail that you know works. Send a simple email from this client so that you have a baseline that you're starting from. Then, switch over to you're existing client. Send the mail again. Does it work? If so, start adding in your logic bit by bit testing each time. It should be pretty clear as to what's breaking.

Categories : PHP

ajax how to pass a dom element to ajax call
If you have many of these fields, perhaps you could give them IDs and pass the appropriate one with your AJAX call. Then do what you need to do with it, and return the ID of what needs to get updated in your callback. Then you could do something like var val = $('.landscape_type#'+id).val();

Categories : Jquery

Sending an AJAX call before all other AJAX calls
UPDATED: Have one method on an interval that sets up the 'session'/local-storage var refreshing = false; var intervalID; $(document).ready(function(e){ var delay = 1234; intervalID = window.setInterval(setupInterval, delay); }); function setupInterval(){ refreshing = true; $.ajax(URL).done(function(r) { //do stuff setupStorage(r); refreshing = false; }); } function setupStorage(info){ //setup whatever here } OLD: Could you use some logic in your ready function to gate what you need to do? So basically call one ajax call -> if false, just schedule your latter methods, otherwise run the setup one and on completion schedule the latter method. Some pseudo-code: var refresh = false; $(document).ready(function(e){ $.ajax(URL).done( function(r) { if(r) {

Categories : Javascript

AJAX: Getting ajax call javascript function
you can use firebug in firefox. It allows you to have breakpoints in javascript code. You can click on the script tab of firebug and select your script file and provide breakpoints at all AJAX calls and see which AJAX is being called last.

Categories : Javascript

Call ajax inside a custom method and return ajax result to called method
The Ajax call is asynchronous and takes its time to complete, while the execution goes on and that's why you don't have any data in the "return". You need to pass a callback function to your callActionUsingAjax and call it in your success handler (or complete or error that depends on the logic. Like this: $(document).on('click', ".addComponent", function(){ //... other stuff callActionUsingAjax(urlAction, dataFields, function (data) { //this is tha callback (third argument) var ajaxActionResult=ajaxResult(data); $('.addComponent').html(htmlContent).fadeIn(); $('#popUpForm').html(ajaxActionResult); $('#popUpForm').dialog("open"); // all of the above happens when ajax completes, not immediately. }); return false; }); function call

Categories : Ajax

Using AJAX To complete autopredict - Not working
I was directed to look in Search.php which contained an infinite loop: while(($row = mysqli_fetch_assoc($query)) !== false) { //loop echo '<li data-id="',$row['id'],'" >',$row['customer_name'],' ',$row['postcode'],'</li>'; Changed it to: while($row = mysqli_fetch_assoc($query)) { //loop echo '<li data-id="',$row['id'],'" >',$row['customer_name'],' ',$row['postcode'],'</li>';

Categories : PHP

Ajax complete don't work with autocomplete
Try triggering the input with the autocomplete change event: //autocomplete $(".auto").autocomplete({ selectFirst:true, source: "Search_bon.php", delay: 0, autoFocus: true, minLength: 1, change: function (event, ui){ $("#username").trigger("change"); } }); ALSO: Make sure the path to url: "check.php", is correct in the .ajax function. If it's off the root, try url: "/check.php",

Categories : PHP



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.