Search Results

Search found 541 results on 22 pages for 'settimeout'.

Page 14/22 | < Previous Page | 10 11 12 13 14 15 16 17 18 19 20 21  | Next Page >

  • JavaScript - Settting property on Object in Image load function, property not set once outside funct

    - by Sunday Ironfoot
    Sometimes JavaScript doesn't make sense to me, consider the following code that generates a photo mosaic based on x/y tiles. I'm trying to set a .Done property to true once each Mosaic image has been downloaded, but it's always false for some reason, what am I doing wrong? var tileData = []; function generate() { var image = new Image(); image.onload = function() { // Build up the 'tileData' array with tile objects from this Image for (var i = 0; i < tileData.length; i++) { var tile = tileData[i]; var tileImage = new Image(); tileImage.onload = function() { // Do something with this tile Image tile.Done = true; }; tileImage.src = tile.ImageUrl; } }; image.src = 'Penguins.jpg'; tryDisplayMosaic(); } function tryDisplayMosaic() { setTimeout(function() { for (var i = 0; i < tileData.length; i++) { var tile = tileData[i]; if (!tile.Done) { tryDisplayMosaic(); return; } } // If we get here then all the tiles have been downloaded alert('All images downloaded'); }, 2000); } Now for some reason the .Done property on the tile object is always false, even though it is explicitly being set to true inside tileImage.onload = function(). And I can ensure you that this function DOES get called because I've placed an alert() call inside it. Right now it's just stuck inside an infinite loop calling tryDisplayMosaic() constantly. Also if I place a loop just before tryDisplayMosaic() is called, and in that loop I set .Done = true, then .Done property is true and alert('All images downloaded'); will get called.

    Read the article

  • Improving long-polling Ajax performance

    - by Bears will eat you
    I'm writing a webapp (Firefox-compatible only) which uses long polling (via jQuery's ajax abilities) to send more-or-less constant updates from the server to the client. I'm concerned about the effects of leaving this running for long periods of time, say, all day or overnight. The basic code skeleton is this: function processResults(xml) { // do stuff with the xml from the server } function fetch() { setTimeout(function () { $.ajax({ type: 'GET', url: 'foo/bar/baz', dataType: 'xml', success: function (xml) { processResults(xml); fetch(); }, error: function (xhr, type, exception) { if (xhr.status === 0) { console.log('XMLHttpRequest cancelled'); } else { console.debug(xhr); fetch(); } } }); }, 500); } (The half-second "sleep" is so that the client doesn't hammer the server if the updates are coming back to the client quickly - which they usually are.) After leaving this running overnight, it tends to make Firefox crawl. I'd been thinking that this could be partially caused by a large stack depth since I've basically written an infinitely recursive function. However, if I use Firebug and throw a breakpoint into fetch, it looks like this is not the case. The stack that Firebug shows me is only about 4 or 5 frames deep, even after an hour. One of the solutions I'm considering is changing my recursive function to an iterative one, but I can't figure out how I would insert the delay in between Ajax requests without spinning. I've looked at the JS 1.7 "yield" keyword but I can't quite wrap my head around it, to figure out if it's what I need here. Is the best solution just to do a hard refresh on the page periodically, say, once every hour? Is there a better/leaner long-polling design pattern that won't put a hurt on the browser even after running for 8 or 12 hours? Or should I just skip the long polling altogether and use a different "constant update" pattern since I usually know how frequently the server will have a response for me?

    Read the article

  • Selenium - Could not start Selenium session: Failed to start new browser session: Error while launching browser

    - by Yatendra Goel
    I am new to Selenium. I generated my first java selenium test case and it has compiled successfully. But when I run that test I got the following RuntimeException java.lang.RuntimeException: Could not start Selenium session: Failed to start new browser session: Error while launching browser at com.thoughtworks.selenium.DefaultSelenium.start <DefaultSelenium.java:88> Kindly tell me how can I fix this error. This is the java file I want to run. import com.thoughtworks.selenium.*; import java.util.regex.Pattern; import junit.framework.*; public class orkut extends SeleneseTestCase { public void setUp() throws Exception { setUp("https://www.google.com/", "*chrome"); } public void testOrkut() throws Exception { selenium.setTimeout("10000"); selenium.open("/accounts/ServiceLogin?service=orkut&hl=en-US&rm=false&continue=http%3A%2F%2Fwww.orkut.com%2FRedirLogin%3Fmsg%3D0&cd=IN&skipvpage=true&sendvemail=false"); selenium.type("Email", "username"); selenium.type("Passwd", "password"); selenium.click("signIn"); selenium.selectFrame("orkutFrame"); selenium.click("link=Communities"); selenium.waitForPageToLoad("10000"); } public static Test suite() { return new TestSuite(orkut.class); } public void tearDown(){ selenium.stop(); } public static void main(String args[]) { junit.textui.TestRunner.run(suite()); } } I first started the selenium server through the command prompt and then execute the above java file through another command prompt. Second Question: Can I do right click on a specified place on a webpage with selenium.

    Read the article

  • jquery stop image rotation on mouseover, start on mouseout / hover

    - by Matt Nathanson
    I have built a jQuery rotator to rotate through 3 divs and loop them. I would like to add the functionality on mouse over to "freeze" the current div and then start again on mouse out. I've thought about setting a variable to false at the start of the function and setting it true when it's on it's current frame but I've got my self a bit confused. I've also tried to use the hover function but when using the in and out handlers, I'm confused as to how to stop, restart the animation. function ImageRotate() { var CurrentFeature = "#container" + featureNumber; $(CurrentFeature).stop(false, true).delay(4500).animate({'top' : '330px'}, 3000); var featureNumber2 = featureNumber+1; if ( featureNumber == numberOfFeatures) {featureNumber2 = 1} var NewFeature = "#container" + featureNumber2; $(NewFeature).stop(false, true).delay(4500).animate({'top' : '0px'}, 3000); var featureNumber3 = featureNumber-1; if ( featureNumber == 1) {featureNumber3 = numberOfFeatures}; var OldFeature = "#container" + featureNumber3; $(OldFeature).stop(false, true).delay(4500).css('top' , '-330px'); setTimeout('if (featureNumber == numberOfFeatures){featureNumber = 1} else {featureNumber++}; ImageRotate2()', 7500)}; Any help would be greatly appreciated!! Thanks, Matt

    Read the article

  • how to show a large jpg image to the right in jqGrid's edit form ?

    - by cLee
    Is it possible to show a large (i.e. bigger than a thumbnail) jpeg image in the right-hand side of jqGrid's edit form ? Users want to look at a photo while entering data into fields ... they are describing things in the photo. I'm sure all things are possible with jQuery, but I don't know where to begin. thanks ... html: function afterSubmit(r, data, action) { // if session timeout returned: if (r.responseText == "logout") { window.location = '../scripts/logout.php'; } // if an error message is returned: if (r.responseText != "") { $('#submit_errors').html('Alert:'+r.responseText+''); // show div with error message $('#submit_errors').slideDown(); // hide error div after 10 seconds window.setTimeout(function() { $('#submit_errors').slideUp(); }, 10000); return false; // don't remove this! } return true; // don't remove this! } var lastsel; jQuery(document).ready(function(){ var mygrid = jQuery("#mobile_incidents").jqGrid({ url:'list.php?q=e', editurl:'edit.php', datatype: "json", // note: all column names are required even though some columns are hidden colNames:['Rec#','Date','Line','Photo'], colModel:[{ name:'id', index:'id', editable:true, editoptions: {readonly:'readonly'} }, { name:'mobile_discoveryDate', index:'mobile_discoveryDate', sortable:false, editable:true, edittype:'text', formatter:'date', formatoptions:{ srcformat:'Y/m/d', newformat:'m/d/Y' }, editoptions:{ size:12, maxlength:10, dataInit: function(element) { $(element).blur(); $(element).datepicker({dateFormat:'mm/dd/yyyy'}) } } }, { name:'mobile_lineName', index:'mobile_lineName', editable:true, sortable:false}, { name:'mobile_photo_name', index:'mobile_photo_name', editable:false, sortable:false} ], pager: '#mobile_incidents_pager', altRows: false, rowNum:10, rowList:[10,20], imgpath: '../include/images/jqgrid', viewrecords: true, emptyrecords:'No submissions found!', height: 260, sortname: 'id', sortorder: 'desc', gridview: true, scrollrows: true, autowidth: true, rownumbers: false, multiselect: false, subGrid:false, caption: '' }) .navGrid('#mobile_incidents_pager', // params: {add:false, edit:true, del:false, search:false, view:false, refresh:true, alertcap:' to edit:', alerttext:' . . . click on a row to highlight' }, // edit params: {top:50, left:5, editCaption: 'Edit Submission', bSubmit: 'Approve/Save', closeAfterEdit:true, afterSubmit:function(r,data){return afterSubmit(r,data,'edit');} }, {}, // add params {}, // delete params // search params: {multipleSearch: false}, // view params: {top: 150, left: 5, caption: 'View Mobile Rail Submission'} ); });

    Read the article

  • Flash/ActionScript3 crashes on getPixel/32

    - by Quandary
    Question: The below code crashes flash... Why? The crash causing lines seem to be //var uiColor:uint = bmpd.getPixel(i,j); var uiColor:uint = bmpd.getPixel32(i,j); trace("Color: "+ uiColor); I am trying to take a snapshot of a movieclip and iterate through all pixels in the image and get the pixel's color. import flash.display.BitmapData; import flash.geom.*; function takeSnapshot(mc:MovieClip):BitmapData { var sp:BitmapData = new BitmapData(mc.width, mc.height, true, 0x000000); sp.draw(mc, new Matrix(), new ColorTransform(), "normal"); return sp; } var mcMyClip:MovieClip=new MovieClip() var xxx:cMovieClipLoader=new cMovieClipLoader(); xxx.LoadImageAbsSize(mcMyClip,"http://localhost/flash/images/picture.gif", 500,500) //this.addChild(mcMyClip); function WhenImageIsLoaded() { var bmpd:BitmapData=takeSnapshot(mcMyClip); var i,j:uint; for(i=0; i < bmpd.width;++i) { for(j=0; j < bmpd.height;++j) { //var uiColor:uint = bmpd.getPixel(i,j); var uiColor:uint = bmpd.getPixel32(i,j); trace("Color: "+ uiColor); } } var myBitmap:Bitmap = new Bitmap(bmpd); this.addChild(myBitmap); } setTimeout(WhenImageIsLoaded,1000);

    Read the article

  • Adding multiple star rating widgets to one page

    - by diglettpotato
    I am using this jQuery plugin for star ratings: http://orkans-tmp.22web.net/star_rating/ Everything is going great, including using AJAX, etc. The problem is that I need to have many per page and can't quite figure out how to work with the selectors to achieve this. I think this is probably very easy for someone who knows their jQuery... Here's some code below... There are multiple kids per page, and I need one rating widget for each kid. I can set up each #rat to be unique with a kid attached to it, like #1rat, #2rat, etc. But then how would I set up the function to be run on each of them independently? <script type="text/javascript"> $(function(){ var kidval=1; //this needs to be setup for each kid... not just 1 var uidval=1; $('#rat').children().not("select, #rating_title").hide(); var $caption = $('<div id="caption"/>'); $('#rat').stars({ inputType: "select", oneVoteOnly: false, callback: function(ui, type, value) { $("#"+kidval+"messages").text("Saving...").fadeIn(30); $.post("vote.php", {rate: value, kid: kidval, uid: uidval}, function(json) { $("#"+kidval+"messages").text("Average"); ui.select(Math.round(json.avg)); $caption.text(" (" + json.votes + " votes, " + json.avg + " avg)"); $("#"+kidval+"messages").text("Rated " + value + " Thanks!").stop().css("opacity", 1).fadeIn(30); setTimeout(function(){ $("#"+kidval+"messages").fadeOut(1000) }, 2000); }, "json"); } }); $('#rat').stars("selectID", -1); $caption.appendTo(#rat); $('<div id="'+kidval+'messages"/>').appendTo(#rat); });

    Read the article

  • GWT JsonpRequestBuilder Timeout issue

    - by Anthony Kong
    I am getting time out from using JsonpRequestBuilder. The entry point code goes like this: // private static final String SERVER_URL = "http://localhost:8094/data/view/"; private static final String SERVER_URL = "http://www.google.com/calendar/feeds/[email protected]/public/full?alt=json-in-script&callback=insertAgenda&orderby=starttime&max-results=15&singleevents=true&sortorder=ascending&futureevents=true"; private static final String SERVER_ERROR = "An error occurred while " + "attempting to contact the server. Please check your network " + "connection and try again."; /** * This is the entry point method. */ public void onModuleLoad() { JsonpRequestBuilder requestBuilder = new JsonpRequestBuilder(); // requestBuilder.setTimeout(10000); requestBuilder.requestObject(SERVER_URL, new Jazz10RequestCallback()); } class Jazz10RequestCallback implements AsyncCallback<Article> { @Override public void onFailure(Throwable caught) { Window.alert("Failed to send the message: " + caught.getMessage()); } @Override public void onSuccess(Article result) { // TODO Auto-generated method stub Window.alert(result.toString()); } The article class is simply: import com.google.gwt.core.client.JavaScriptObject; public class Article extends JavaScriptObject { protected Article() {}; } The gwt page, however, always hit the onFailure() callback and show this alert: Failed to send the message. Timeout while calling <url>. Fail to see anything on the Eclipse plugin console. I tried the url and it works perfectly. Would appreciate any tip on debugging technique or suggestion

    Read the article

  • WOT Bookmarklet

    - by S.A
    I'm trying to write a bookmarklet that will allow me to view the Web Of Trust (WOT) ratings for all the links on a page before visiting them. While WOT provides their own bookmarklet, it is not very useful since you need to visit the page first before viewing the rating. This will be used on SeaMonkey, so I can't just install the WOT extension, either. WOT has a Javascript API that allows you to activate the ratings on any page it is included in, so I am using that as a base. However, it never seems to work correctly as a bookmarklet. Here's one attempt where I tried to keep the code as close to the API as possible. I only modified the wotinject function so that it would work in a bookmarklet and added a timeout so that the rating widget wouldn't be loaded before jQuery. var wotprotocol = (document.location.protocol == "https:") ? "https://" : "http://"; var wotbase = wotprotocol + "api.mywot.com/widgets"; var wotinject = function(src) { document.body.appendChild(document.createElement("script")).src = wotbase + "/" + src + ".js"; }; var wotjquery = typeof(jQuery) != "undefined"; if (!wotjquery) { wotinject("jquery"); } void(window.setTimeout(wotinject, 200, "ratingwidget")); I can see the APIs being loaded in the status bar, but it doesn't do anything at all. Is there any way to get this working?

    Read the article

  • Showing right sub-ul of parent ul menu

    - by Micke
    Hello, i have this html menu: <ul id='main'> <li class='active current' id='lighty'> <a href='/'>Lighty</a> <ul> <li class='sub'> <a href='/'>Hem</a> </li> </ul> </li> <li id='community'> <a href='/community'>Community</a> </li> </ul> And this jquery: $("#menu ul > li").mouseenter(function(){ id = $(this).attr("id"); $("#menu #main li").removeClass("active"); $(this).addClass("active"); }).mouseleave(function(){ id = $(this).attr("id"); menu.timers[id] = setTimeout(function(){$("#menu #main li#"+id).removeClass("active");}, 2000); }); What i am trying to acomplish is that when i hover one of the li's in the main ul the child ul of that li should be displayed. and when i move the mouse out of the li or the child ul the menu should be visible for 2 seconds. It works through the main li button but if on the child ul and move out it just disapears, it doesnt wait for two seconds. The waiting two seconds is so you can go in to the menu if you accidentaly move the mouse out of it. Can anybody help me to fix this error? Maybe you have a better solution? Here is also a screenshot on how the menu looks if it helps: screen shot under or click here

    Read the article

  • JQuery Simple Modal OSX Multiple dialogs

    - by Aneef
    HI, I'm planning to use the jquery Simple modal for login and registration on my project site. i tried to have 2 modals as mentioned here. but im still unable to make it work. here is my code jQuery(function ($) { var OSX = { container: null, init: function () { $("a.osx").click(function (e) { e.preventDefault(); $(this.id + "_osx-modal-content").modal({ overlayId: this.id+'_osx-overlay', containerId: this.id+'_osx-container', closeHTML: null, minHeight: 80, opacity: 65, position: ['0',], overlayClose: true, onOpen: OSX.open, onClose: OSX.close }); }); }, open: function (d) { var self = this; self.container = d.container[0]; d.overlay.fadeIn('slow', function () { $("#osx-modal-content", self.container).show(); var title = $("#osx-modal-title", self.container); title.show(); d.container.slideDown('slow', function () { setTimeout(function () { var h = $("#osx-modal-data", self.container).height() + title.height() + 20; // padding d.container.animate( {height: h}, 200, function () { $("div.close", self.container).show(); $("#osx-modal-data", self.container).show(); } ); }, 300); }); }) }, close: function (d) { var self = this; // this = SimpleModal object d.container.animate( {top:"-" + (d.container.height() + 20)}, 500, function () { self.close(); // or $.modal.close(); } ); } }; OSX.init(); I guess its something to do with the open: function part, anyone can help me ?

    Read the article

  • javascript using 'this' in global object

    - by Marco Demaio
    What does 'this' keyword refer to when used in gloabl object? Let's say for instance we have: var SomeGlobalObject = { rendered: true, show: function() { /* I should use 'SomeGlobalObject.rendered' below, otherwise it won't work when called from event scope. But it works when called from timer scope!! How can this be? */ if(this.rendered) alert("hello"); } } Now if we call in an inline script in the HTML page: SomeGlobalObject.show(); window.setTimeout("Msg.show()", 1000); everything work ok. But if we do something like AppendEvent(window, 'load', Msg.show); we get an error because this.rendered is undefined when called from the event scope. Do you know why this happens? Could you explain then if there is another smarter way to do this without having to rewrite every time "SomeGlobalObject.someProperty" into the the SomeGlobalObject code? Thanks! AppendEvent is just a simple cross-browser function to append an event, code below, but it does not matter in order to answer the above questions. function AppendEvent(html_element, event_name, event_function) { if(html_element.attachEvent) //IE return html_element.attachEvent("on" + event_name, event_function); else if(html_element.addEventListener) //FF html_element.addEventListener(event_name, event_function, false); }

    Read the article

  • Problem in IE8 with GET Parameters in opening a new windows with javascript.

    - by amfa95
    Hi, I have a problem with IE8 and the opening of a new window with javascript and submitting parameters with special characters. <a href="javascript:oWin('/html/de/4664286/printregistrationcontent.html?12-security question&#61;Wie hei&#223;t Ihr Lieblingsrestaurant','PRINT',800,600);" class="print">Seite drucken</a> The Problem is the letter 'ß' (sharp S). As you can see the string above is encodes due to anti XSS. This link works in FF and IE6 but IE8 is transmitting the URL Parameter as character with code 65*** (don't know the exaxt value). In the opening window you will only see a square (because character with 65000+ is not printable). I also tried to use URL Encoding instead of HTML encoding <a href="javascript:oWin('/html/de/4664286/printregistrationcontent.html?12-security question%3DWie hei%C3%9Ft Ihr Lieblingsrestaurant','PRINT',800,600);" class="print">Seite drucken</a> If i click on this Link in FF or IE6 it works as expected, but IE8 will fail to transmit the "ß" to the server and therefor will also get it back in the wrong way. If i paste this url to the IE8 it will work too, but not if the window is opened by javascript. The Javascript function oWin is defined as follows function oWin(url,title,sizeH,sizeV) { winHandle = top.open(url,title,'toolbar=no,directories=no,status=yes,scrollbars=yes,menubar=no,resizable=no,width='+sizeH+',height='+sizeV); if(navigator.appVersion.indexOf("MSIE 3",0)==-1) id = setTimeout('winHandle.focus()',1000); } If someone has an idea where to look for the reason please answer to this. Thank you amfa

    Read the article

  • SoundManager2 has irregular latency

    - by Stefan Monov
    I'm playing some notes at regular intervals. Each one is delayed by a random number of milliseconds, creating a jarring irregular effect. How do I fix it? Note: I'm OK with some latency, just as long as it's consistent. Answers of the type "implement your own small SoundManager2 replacement, optimized for timing-sensitive playback" are OK, if you know how to do that :) but I'm trying to avoid rewriting my whole app in flash for now. For an example of app with zero audible latency see the flash-based ToneMatrix. Testcase (see it here live or get it in an zip): <head> <title></title> <script type="text/javascript" src="http://www.schillmania.com/projects/soundmanager2/script/soundmanager2.js"> </script> <script type="text/javascript"> soundManager.url = '.' soundManager.flashVersion = 9 soundManager.useHighPerformance = true soundManager.useFastPolling = true soundManager.autoLoad = true function recur(func, delay) { window.setTimeout(function() { recur(func, delay); func(); }, delay) } soundManager.onload = function() { var sound = soundManager.createSound("test", "test.mp3") recur(function() { sound.play() }, 300) } </script> </head> <body> </body> </html>

    Read the article

  • XMLHttpRequest leak in javascript. please help.

    - by Raja
    Hi everyone, Below is my javascript code snippet. Its not running as expected, please help me with this. <script type="text/javascript"> function getCurrentLocation() { console.log("inside location"); navigator.geolocation.getCurrentPosition(function(position) { insert_coord(new google.maps.LatLng(position.coords.latitude,position.coords.longitude)); }); } function insert_coord(loc) { var request = new XMLHttpRequest(); request.open("POST","start.php",true); request.onreadystatechange = function() { callback(request); }; request.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); request.send("lat=" + encodeURIComponent(loc.lat()) + "&lng=" + encodeURIComponent(loc.lng())); return request; } function callback(req) { console.log("inside callback"); if(req.readyState == 4) if(req.status == 200) { document.getElementById("scratch").innerHTML = "callback success"; window.setTimeout("getCurrentLocation()",5000); } } getCurrentLocation(); //called on body load </script> What i'm trying to achieve is to send my current location to the php page every 5 seconds or so. i can see few of the coordinates in my database but after sometime it gets weird. Firebug show very weird logs like simultaneous POST's at irregular intervals. Here's the firebug screenshot: IS there a leak in the program. please help.

    Read the article

  • Accessing Current URL using Prototype

    - by Jason Nerer
    Hi folks, following Ryan Bates Screencast #114 I'm trying to generate endless pages using prototype. In difference to Ryan's showcase my URL called via the AJAX request shall be handled dynamically, cause I do not always call the same URL when the user reaches the end of my page. So my JS running in backround looks like that and uses document.location.href instead a fixed URL: var currentPage = 1; function checkScroll() { if (nearBottomOfPage()) { currentPage++; new Ajax.Request(document.location.href + '?page=' + currentPage, {asynchronous:true, evalScripts:true, method:'get'}); } else { setTimeout("checkScroll()", 250); } } function nearBottomOfPage() { return scrollDistanceFromBottom() < 10; } function scrollDistanceFromBottom(argument) { return pageHeight() - (window.pageYOffset + self.innerHeight); } function pageHeight() { return Math.max(document.body.scrollHeight, document.body.offsetHeight); } document.observe('dom:loaded', checkScroll); The question is: The code seems to work in Safari but fails in FF 3.6. It seems that FF calculates scrollHeight or offsetHeight differently. How can I prevent that? Thx in advance. Jason

    Read the article

  • Looped jQuery slideshow with smooth cross-fades

    - by artlung
    I'm trying to do a simple rotating image on the home page. Under the hood I'm reading a directory and then populating urls for the images into an array. What I want to do is cross-fade the images. If it was just a matter of showing the next one, it's easy, but since I need to cross-fade, it's a bit harder. I think what I want to do is do the fades by calling animate() on the opacity value of the <img> tag, and in between swapping out the css background-image property of the enclosing <div>. But the results are not that great. I've used tools for more full featured slideshows, but I don't want the overhead of adding a plugin if I can avoid it, and a simple crossfade seems like it should be easier. Here's my JavaScript (I'm using jQuery 1.3.2): var slideshow_images = ["http:\/\/example.com\/wordpress\/wp-content\/themes\/testtheme\/sidebar-home-bg\/bg1.jpg","http:\/\/example.com\/wordpress\/wp-content\/themes\/testtheme\/sidebar-home-bg\/bg2.jpg","http:\/\/example.com\/wordpress\/wp-content\/themes\/testtheme\/sidebar-home-bg\/bg3.jpg"]; var slideshow_index = 0; var delay = 4000; var swapSlides = function() { var slideshow_count = slideshow_images.length; // initialize the background to be the current image $('#home-slideshow').css({ 'background-image': 'url(' + slideshow_images[slideshow_index] + ')', 'background-repeat:': 'no-repeat', 'width': 200, 'overflow': 'hidden' }); slideshow_index = ((slideshow_index + 1) == slideshow_count) ? 0 : slideshow_index + 1; // fade out the img $('#home-slideshow img').animate({opacity: 0}, delay); // now, the background is visible // next change the url on the img $('#home-slideshow img').attr('src', slideshow_images[slideshow_index]); // and fade it up $('#home-slideshow img').animate({opacity: 1.0}, delay); // do it again setTimeout('swapSlides()', 4000); } jQuery(document).ready(function(){ if (swapSlides) { swapSlides(); } }); And here's the markup I'm using: <div id="home-slideshow"><img src="http://example.com/wordpress/wp-content/themes/testtheme/sidebar-home-bg/bg1.jpg" alt="" /></div>

    Read the article

  • Trigger element's onclick method with JQuery [ASP.NET]

    - by blu
    I have an ASP.NET server control that inherits from CheckBoxList that renders the controls with a UL and LIs. The control is set to AutoPostBack. Markup: <div id="foo"> <ul> <li> <input type="checkbox" onclick="javascript:setTimeout('__doPostBack(..." ... /> <label ... /> </li> </ul> </div> I would like to trigger the JavaScript that is rendered on the CheckBox when the parent LI is clicked. Here is what I have so far: $("#foo li").click(function() { $(this).find("input:eq(0)").trigger("click"); }); This fires a postback in FF 3.x but the event handler in the codebehind is not fired. In IE 7 a script error comes up and the browser just kind of hangs there for a bit then reloads the page. How should I be doing this?

    Read the article

  • JSON parse failed

    - by Mesut
    hello i haven an error abour ajax post success. after the success function i added code for lookin for errors ... else if (exception === 'parsererror') { alert('Requested JSON parse failed.'); ... on my php code: echo json_encode(array('msg' => $msg, 'myClass' => $class)); returns back after my function. i checked in firebug and it returns like, response like {"msg":"Kayd\u0131n\u0131z Ba\u015far\u0131l\u0131","myClass":"alert alert-success"} html like {"msg":"Kayd\u0131n\u0131z Ba\u015far\u0131l\u0131","myClass":"alert alert-success"} there is no json tab on firebug and on my ajax code if i comment the dataType: "json", my success function is working but i cant get the response.msg or response.myClass, if i dont comment it, success function is not working, here is the ajax code $.ajax({ type: "POST", url: "index.php?page=addItem&action=addItem&edit=true", data: dataString, success: function(response) { $("#message").html(response.msg); $("#message").addClass(response.myClass); $("#itemForm").fadeOut("slow"); window.setTimeout('location.href = "index.php?page=addItem"', 1000); } });

    Read the article

  • Google Chrome, IE problem with adjusting style before AJAX

    - by orokusaki
    When I'm using AJAX, I typically do something before each request to let the user know that they'll be waiting for a second. This is usually done by just adding an animated loading gif. When I do this, Firefox does what you'd expect and adds the gif before moving control to the next line (where the AJAX is called). In Chrome, it locks the browser and doesn't make any DOM changes at all (let alone load an image), including even changing the color of something, until the AJAX is done. This isn't just AJAX though. It's anything that holds control, and it never makes DOM changes until the control is given back to the window. Example (using jQuery): function submit_order() { $('#my_element').css('color', '#FF0000'); // Make text red before calling AJAX $.getJSON('/api/', my_callback) // Note, in IE and Chrome #my_element isn't turned red until the AJAX finishes and my_callback is run } Why does this happen, and how can I solve it? I can't use ASYNC because of the nature of the data (it would be a big mess). I experimented with using window.setTimeout(myajaxfunc, 150) after setting the style, to see if it would set the style, then do the timeout, but it appears it isn't an issue with just AJAX, but rather the control of the script in general (I think, hence the title making mention to AJAX because this is the only time I ever run into this problem). This doesn't have anything to do with it being in a function BTW.

    Read the article

  • Get "term is undefined” error when trying to assign arrayList to List component dataSource

    - by user1814467
    I'm creating an online game where people log in and then have the list of current players displayed. When the user enters a "room" it dispatches an SFSEvent which includes a Room object with the list of users as User objects in that room. As that event's callback function, I get the list of current users which is an Array, switch the View Stack child index, and then I wrap the user list array in an ArrayList before I assign it to the MXML Spark List component's dataSource. Here's my code: My Actionscript Code Section (PreGame.as): private function onRoomJoin(event:SFSEvent):void { const room:Room = this._sfs.getRoomByName(PREGAME_ROOM); this.selectedChild = waitingRoom; /** I know I should be using event listeners * but this is a temporary fix, otherwise * I keep getting null object errors * do to the li_users list not being * created in time for the dataProvider assignment **/ setTimeout(function ():void { const userList:ArrayList = new ArrayList(room.userList); this.li_users.dataProvider = userList; // This is where the error gets thrown },1000); } My MXML Code: <?xml version="1.0" encoding="utf-8"?> <mx:ViewStack xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" initialize="preGame_initializeHandler(event)" > <fx:Script source="PreGame.as"/> <s:NavigatorContent id="nc_loginScreen"> /** Login Screen Code **/ </s:NavigatorContent> /** Start of Waiting Room code **/ <s:NavigatorContent id="waitingRoom"> <s:Panel id="pn_users" width="400" height="400" title="Users"> /** This is the List in question **/ <s:List id="li_users" width="100%" height="100%"/> </s:Panel> </s:NavigatorContent> </mx:ViewStack> However, I keep getting this error: TypeError: Error #1010: A term is undefined and has no properties Any ideas what I'm doing wrong? The arrayList has data, so I know it's not empty/null.

    Read the article

  • jQuery image preload/cache halting browser

    - by Nathan Loding
    In short, I have a very large photo gallery and I'm trying to cache as many of the thumbnail images as I can when the first page loads. There could be 1000+ thumbnails. First question -- is it stupid to try to preload/cache that many? Second question -- when the preload() function fires, the entire browser stops responding for a minute to two. At which time the callback fires, so the preload is complete. Is there a way to accomplish "smart preloading" that doesn't impede on the user experience/speed when attempting to load this many objects? The $.preLoadImages function is take from here: http://binarykitten.me.uk/dev/jq-plugins/107-jquery-image-preloader-plus-callbacks.html Here's how I'm implementing it: $(document).ready(function() { setTimeout("preload()", 5000); }); function preload() { var images = ['image1.jpg', ... 'image1000.jpg']; $.preLoadImages(images, function() { alert('done'); }); } 1000 images is a lot. Am I asking too much?

    Read the article

  • PHP APC and Pecl upload progress returning false/null.

    - by Keyo
    This is a long shot. I believe this might be suhosin patch issue. Here is my php from codeigniter: public function uploadprogress($id) { if ($id) { header("Cache-Control: no-cache, must-revalidate"); header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); echo json_encode(apc_fetch('upload_'.$id)); exit(); } } public function uploader() { $this->load->view('myid/' . $this->router->class . '_uploader'); //phpinfo(); } script: <script type="text/javascript"> $(document).ready(function(){ var progress_key = $('#progress_key').val(); // this sets up the progress bar $('#uploadform').submit(function() { setTimeout(beginUpload,1500); return; }); function beginUpload() { $("#progressbar").progressbar({ value:0}).fadeIn(); var i = setInterval(function() { $.getJSON("/myid/videos/uploadprogress/" + progress_key, function(data) { alert('data'); if (data == null) { clearInterval(i); location.reload(true); return; } var response; eval ("response = " + data); if (!response) return; var percentage = Math.floor(100 * parseInt(response['bytes_uploaded']) / parseInt(response['bytes_total'])); $("#progressbar").progressbar({value:percentage}); }, 1500); }); } }); </script> Has anyone had strange troubles with this before? The upload key is the same on the view and the uploadprogress method. I've Tried apc and pecl upload-progress both return false or null. I wondering if it's just suhosin patch messing up everything?

    Read the article

  • jQuery hover DIV- stay active if they hover over the DIV itself

    - by Lock
    I have a DIV that opens up when an image is hovered. When the user leaves the image, the div disappears after a timeout. How can I make it so that the DIV will stay active if the user was to hover over the DIV itself? So the DIV will stay active as long as the user is on the image or the DIV itself? I am using the following: $(document).ready(function() { $(".hover").hover( function(e){ if ( $("#status").is(":hidden")) { var ref = $(this).attr("wsref"); var url = "https://site/_ref/shop/_base/order_status.php?action=getstatus&ref="+ref+"&sid="+Math.random(); $("#status").show(); var height = $(".status").height(); var width = $(".status").width(); leftVal = e.pageX - width -10 + "px"; topVal = e.pageY - height -10 + "px"; $("#status").css({left:leftVal,top:topVal}); $("#status").html("<div id='loading'></div>").load(url); } }, function() { if ( $("#status").is(':visible')) { setTimeout('$("#status").hide()',0); } }); }); HTML <a href="#"><img class="hover" title="Order Received" name="Order Received" src="https://site/_ref/images/cart.png" wsref="002731"/></a>

    Read the article

  • Updating / refreshing a geojson layer

    - by Ozaki
    TLDR My geoJSON layer will display the vector mark but will not destroy the features or re add the features in causing a moving / updating look to the OpenLayers map. Hey S O. I have a geojson layer set up as follows: //GeoJSON Layer// var layer1 = new OpenLayers.Layer.GML("My GeoJSON Layer", "coordinates", {format: OpenLayers.Format.GeoJSON, styleMap: style_red}); My features are set up as follows: var f = new OpenLayers.Feature.Vector(null,style_red); var style_red = OpenLayers.Util.extend({}, layer_style); style_red.strokeColor = "red"; style_red.fillColor = "black"; style_red.fillOpacity = 0.5; style_red.graphicName = "circle"; style_red.pointRadius = 3.8; style_red.strokeWidth = 2; style_red.strokeLinecap = "butt"; and my layer updating function: function UpdateLayer(){ var p = new OpenLayers.Format.GeoJSON({ 'internalProjection': new OpenLayers.Projection("EPSG:900913"), 'externalProjection': new OpenLayers.Projection("EPSG:4326") }); var url = "coordinates.geojson"; OpenLayers.loadURL(url, {}, null, function(r) { var f = p.read(r.responseText); map.layers[1].destroyFeatures(); map.layers[1].addFeatures(f); }); setTimeout("UpdateLayer()",1000) } Any idea what I am doing wrong or what I am missing?

    Read the article

< Previous Page | 10 11 12 13 14 15 16 17 18 19 20 21  | Next Page >