php - jQuery ajaxForm complete works sometimes, other times it only fires a native javascript function then stops -
this may duplicate of this topic, must revive issue seems little deeper this. i'm using ajaxform() submit 4 question quiz php script, receive result, , populate div. beforesend
function fires, sending information ajax.php
script. beforesend
shows loading graphic in quiz container. complete
function fires ajax.php
returns html populated dom. @ point, stops. next line call slideup
loading div , display returned information in quizcontainer.
at point if put in javascript alert
fires, meaning complete
@ least firing when should, jquery reference loading div ignored. here's code javascript file handles submission - section handling "handle quiz submission":
$(document).ready(function () { // rid of message box after 15 seconds settimeout(function() { $('#message').slideup('fast'); }, 10000); // handle course list lis $('#courselist li').on('click', function () { // background color it's set var color = $(this).attr('ocolor'); jquery('div', this).toggle('slow', function () { if ($(this).is(":hidden")) { $(this).css('background-color', color); } }); // change background same content background when it's expanded if ($(this).is(":hidden")) { $(this).css('background-color', '#33cc66'); } else { $(this).removeattr('style'); } }); // handle quiz submission jquery.fn.exists = function(){return this.length>0;} if ($('#quizform').exists()) { $('#quizform').ajaxform({ beforesend: function() { $('#quizcontainer').slideup('fast', function () { $('#loading').show(); }); }, complete: function(xhr, thestatus) { alert(thestatus); $('#loading').slideup('fast', function () { $('#quizcontainer').html(xhr.responsetext); $('#quizcontainer').show(); }); } }); } });
if necessary can provide more information , temporary login access if see in action. i'm using jquery 1.8.1(.)
thanks help! jon
i believe first argument of complete
function xhr.responsetext
rather xhr
object third argument. try removing .responsetext
complete:
function.
Comments
Post a Comment