w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories
function runs in chrome but doesn't run in Firefox says function not defined
The use of function statements in JavaScript is discouraged. Check out Mozilla's page on function scope which has a great section on function statements vs. function expressions, and states: Functions can be conditionally defined using either //function statements// (an allowed extension to the ECMA-262 Edition 3 standard) or the Function constructor. Please note that such function statements are no longer allowed in ES5 strict. Additionally, this feature does not work consistently cross-browser, so you should not rely on it. The fact that you are seeing differences between browsers with this code is not surprising. Try var tile1 = function () { ... } While this should work for you here, it does so only because variable definitions with var are hoisted. As JavaScript evol

Categories : Javascript

pause event while function runs
You can use $.off to unbind an event, but I would recommend to just use a variable to keep track if its been triggered or not. This snippet will prevent f from being called until the scrolling has been set to false again. $(window).scroll(function(){ if(this.scrolling == undefined) this.scrolling = false; if(this.scrolling == false){ this.scrolling = true; f(); } }); function f(){ //execute code window.scrolling = false; }

Categories : Javascript

Function runs on CLI but not from bash script
This is most likely caused because of too strong quoting. This error line bash: /bin/echo 'hello'; bash -l: No such file or directory shows that bash does not try to execute the command /bin/echo with the argument 'hello' followed by the command bash -l. Instead bash is trying to execute the command /bin/echo 'hello'; bash -l. Compare: $ ssh localhost -t "/bin/echo 'foo'; bash -l" foo $ logout # this is the new shell Connection to localhost closed. and: $ ssh localhost -t '"/bin/echo 'foo'; bash -l"' bash: /bin/echo foo; bash -l: No such file or directory Connection to localhost closed. The solution to this problem usually involves eval, but I cannot tell for sure unless I see more code from you.

Categories : Bash

Function runs successfully once then fails continously
the first argument of setInterval needs to be a function. window.setInterval( function() { $.get(url,function(data) { if (data.GhStatus == 0) { $('#GhCsStatus_CS').buttonMarkup({ icon: 'myapp-cs' }); alert('crash'); } else { $('#GhCsStatus_GH').buttonMarkup({ icon: 'myapp-gh' }); alert('running'); } if (data.CsStatus == 0) { $('#GhCsStatus_CS').buttonMarkup({ icon: 'myapp-cs' }); alert('crash'); } else { $('#GhCsStatus_GH').buttonMarkup({ icon: 'myapp-gh' }); alert('running'); } }, "json") },

Categories : Javascript

Javascript function runs long after it is called
I think the problem you are actually facing is not that progress is run once when the for loop finishes, but that the div where you are trying to reflect that change is updated only when the windowsFillProcessTable finishes executing. Since JavaScript is single threaded (for now) the execution of windowsFillProcessTable blocks every other processing, including DOM update. You'll have to find an alternative scheme to make the update to your progress bar. See this or this for possible options.

Categories : Javascript

Python Canvas: function runs without being called
In the line of code canv.tag_bind(obj,'<Double-1>',Yellow()) The expression Yellow() calls the function called Yellow. In order to simply refer to a function (say to bind it to an event) instead of calling it, you should just write Yellow. So your code should instead read canv.tag_bind(obj,'<Double-1>',Yellow)

Categories : Python

function not being called first time script runs
First of all, I don't see the advantage of declaring the label variable with global scope in the context of the code you've shared. Since you're returning a label from the getLabel function then I think you should just declare var label; at the top of the getLabel function and return the value of that local variable from the function. Second, the only way I can see that "undefined" would be returned from getLabel is if f.attributes.label is undefined. I would try a code block such as: } else { // is not cluster if (f.attributes.label != null && typeof(f.attributes.label != "undefined") { // if (f.attributes.label) { // alternate simpler if statement label= " " + f.attributes.label; } else { label = " "; } }

Categories : Javascript

Draggable element runs click function
As suggested in my comment you can add a class to the element (eg dragging) when you start dragging in the start function of the draggable, than check in the click handler if the element (or the parent of it in your case) have to class or alternatively fire the function. Code: $(document).ready(function () { $('.container').draggable({ start: function (event, ui) { $(this).addClass('dragging'); } }); $('.clickable').click(function (event) { if ($(this).parent().hasClass('dragging')) { $(this).parent().removeClass('dragging'); } else { //alert("real click"); $("#content").toggle(); } }); }); Maybe there are alternatives to this, but is the only solution that I used. Demo: http://js

Categories : Jquery

Node: How to ensure a function runs ONLY after an object has been created?
There are two possible asynchronous executions which can get you these results : cheerio.load has not finished before createProduct is called. In createProduct product is not getting populated or partially like description before callback is called (not sure). You can use async library to make functions execute synchronously (by using async.series). If createProduct is asynchronous as well , you will have to make it synchronous in similar way. async.series([ function(callback){ $ = cheerio.load(body); callback(); }, function(callback){ createProduct(obj, function(product){ lookUp(product); }); callback(); } ]);

Categories : Javascript

Making a Queue for a function so it only runs once at a time in python
Concurrency access to a shared resource is a well known problem. Python thread provide some mechanism to avoid issues. Use python locks : http://docs.python.org/2/library/threading.html#lock-objects Lock are used to synchronize access to a shared resource : lock = Lock() lock.acquire() # will block if lock is already held ... access shared resource lock.release() More information : http://effbot.org/zone/thread-synchronization.htm Search for "Python synchronization"

Categories : Python

Powershell Function runs for each item in array (I don't want this to happen)
The switch statement fires for each element of the array. This behavior is documented (check Get-Help about_Switch): If the test value is a collection, such as an array, each item in the collection is evaluated in the order in which it appears. Use a regular conditional instead (since you have only 2 cases anyway): if ($attachArray -eq $null) { Send-MailMessage -SmtpServer "internalrelay.corp.local" ` -From "test@andylab.local" -To $toAddresses ` -Subject "There should really be something more informative here" ` -BodyAsHTML $SCRIPT:htmlBody } else { Send-MailMessage -SmtpServer "internalrelay.corp.local" ` -From "test@andylab.local" -To $toAddresses ` -Subject "There should really be something more informative here" ` -BodyAsHTML $SCRIPT:htmlBody -At

Categories : Powershell

Object.keys function in JS file that runs from Java
This method is not defined for the Object class in Rhino. The Rhino documentation states: Rhino contains All the features of JavaScript 1.7 The Mozilla JavaScript documentation states Object.keys was: Introduced in JavaScript 1.8.5 The same Object.keys documentation includes an example of how to add this to previous version of JavaScript.

Categories : Java

jQuery .each function runs over and ajax response showing later
Waiting for asynchronous calls, as you're doing here, are designed to not block any other code that you're running. So the each loop will loop regardless of a response. So your solution is a different pattern. First save your jQuery objects in an array var user_checkboxes = []; user_checkboxes = $('#users input:checkbox'); And then only submit the user at index 0 first. function submitPost(){ if(user_checkboxes.length === 0) return; var user = user_checkboxes[0]; var a = (user.is(':checked')) ? user.val() : ""); if (a != ""){ postToPage(a) // a = PageId|AccessToken <option>PageId|AccessToken</option> } } In your response from the Ajax call you can do this FB.api('/' + d, { fields: 'access_token'}, function (b) { if (dataSepra

Categories : Javascript

jQuery keypress .val() returns previous value after function runs
I have checked the link. Use the 'keyup' event. It works. This is due to when you use the keydown or keypress event then the event function runs before the value of the input tag is updated because it is keydown. If you try the code by pressing the key for sometime then you will see the function runs immediately. But on keyup the function will run after the key is released and updated therefore.

Categories : Jquery

method return value call before function runs in program
The method in main class call doesn't return correct result for bool a1 and a2. Maybe you checked your boolean variable on the line before calling the CompareMyValue-Function? I tested your code in a sample project and it worked fine for me: bool a1 = _check.CompareMyValue(1, 1); System.Diagnostics.Debug.Print(a1.ToString()); // prints true bool a2 = _check2.CompareMyValue("xyz", "xyz"); System.Diagnostics.Debug.Print(a2.ToString()); // prints true bool a3 = _check2.CompareMyValue("x", "y"); // another example System.Diagnostics.Debug.Print(a3.ToString()); // prints false

Categories : C#

function not setting cookie till after the index runs
$_COOKIE is created before your code is processed just like $_POST and $_GET. If you initiate the cookie after page load it will be empty. What you can do is this: $cookie = functionX('random'); function functionX($key) { if(isset($_COOKIE['cookie'][$key]) { return $_COOKIE['cookie'][$key]; } else { $randomvar = 'whatever'; setcookie("cookie[$key]", $randomvar, time()+60*60*24*30, "/", "www.myweburl.com", 0, true); return $randomvar; } }

Categories : PHP

How can I write a non-clickable link that runs a javascript function upon click?
Skip.addEventListener('click', reloadPage(), true); // ^^------------------- Should be: Skip.addEventListener('click', reloadPage, true); You want the callback to be reloadPage not what reloadPage returns.

Categories : Javascript

Assigning .onmousedown with () runs the function when assigned , work arounds
You can use ecmaScript5 bind function, to bind the context and set the arguments to be passed in. image[i].onmousedown = whatever.bind(this, name, what, when, where, how ); this here will be the current context where you are binding the event. If you want to get the context of the element itself then: image[i].onmousedown = whatever.bind(image[i], name, what, when, where, how ); As mentioned in MDN you can place this script in your js for older browser support. if (!Function.prototype.bind) { Function.prototype.bind = function (oThis) { if (typeof this !== "function") { // closest thing possible to the ECMAScript 5 internal IsCallable function throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable"); } var aArgs = Arr

Categories : Javascript

Function crashing in release mode but runs flawless in debugger
I would check the return value of malloc() and use perror() to describe what error has occured. Also here is the documentation for malloc() and perror(). if((product = (MONOM*)malloc(phSize*sizeof(MONOM))) == NULL) { perror("ERROR: Failed to malloc "); return 1; //perror() will display a system specified string to describe the error it may tell you the error } Also do you know the size of MONOM? If not add the following line to your code. printf("MONOM SIZE = %i ", sizeof(MONOM));

Categories : C

My function runs successfully, but the database shows a row with zeros or blank space
The problem is that you aren't specifying POST as the method in your form, but you are trying to read the form variables from the $_POST variable. See this thread: What is the default form posting method? for information about the form defaults. To fix it, you just need to change your form to this: <form action='projectadded.php' name="addnewproject" onsubmit="return(validate());" method="POST"> There are some other things you should change in here, like sanitizing your inputs before putting them into the database, but those aren't the root of your problem.

Categories : PHP

Python: Even after an if runs, the else still runs as well
Some errors I see (my apologies if they're already in your code): Your variable target_card only holds the value of the card, not the suit. You may need to parse the full card in two, since those include both a suit and a value That's not a proper use of the del command; you don't need to set it equal to anything or test for an equality. It would also be helpful to post what errors you got, to help us troubleshoot. Also, I don't think this is how Go Fish is played..

Categories : Python

No Test Runs Listed Under 'Test Runs'
Well, Test Results window is dropped in VS2012 http://connect.microsoft.com/VisualStudio/feedback/details/750184/test-results-window-does-not-show-test-results

Categories : Dotnet

Persistence c#, Between two runs
You could save it in the configuration file, or you could save it in the registry. You can do both... You only have to choose. I don't like very much the registry, so I normally use the configuration file. Here there is the MSDN page that explain how to use Settings in C#.

Categories : C#

Travis CI runs only one test
It sounds like you are using progress reporter (which does rewrite the terminal output) and the output is clobbered with log or something. Try using --reporters dots on Travis.

Categories : Angularjs

Background runs behind button
This might be done in a lot of ways, here's just my first idea: Use a mask like this: Make sure your background-image covers the whole button Insert two white divs above the background-image: left & right of your button Insert a Mask like the above as the buttons background Due to the transparent area (indicated by the texture) you are able to display a border-like part of your background image while the rest of it stays invisible, because its overlapped. I illustrated the result of the instructions above

Categories : HTML

Saving Javadoc across runs
It's a weird behavior, the class files should know where the javadoc is after you added it for the first time. Are you using a simple Java project? What you could do is make a lib folder in your project, copy the JARs and source there, and then add them to the build path. As much as possible , try avoiding external dependencies. You never know when they'll just be gone from where they were.

Categories : Java

Two Mac Apps: why does one run in my Mac and in VMWare 5 VM ,while the other runs on Mac only?
This was all my fault. App1 does not support iCloud. App2 does. My goof was the following. I had enabled iCloud on my Mac but not on the VMWare virtual machine. Like any physical machine I needed to turn on iCloud on in the Settings of the OS X virtual machine. Mark

Categories : Osx

JQuery Animate only runs once
Try this, it will solve your problem $(function() { $("#mission").hover(function () { $(".to-be-hidden").each(function( index ) { $(this).stop().animate({opacity: 0.5}, "slow"); $('#feat-hover').stop().animate({'opacity': '1.0'}, "slow"); });}, function () { $(".to-be-hidden").each(function( index ) { $(this).stop().animate({opacity: 1.0}, "slow"); $('#feat-hover').stop().animate({'opacity': '0'}, "slow"); }); }); });

Categories : Jquery

When I dblclick, it runs .click twice
Per the jQuery documentation for the dblclick event: It is inadvisable to bind handlers to both the click and dblclick events for the same element. The sequence of events triggered varies from browser to browser, with some receiving two click events before the dblclick and others only one. Double-click sensitivity (maximum time between clicks that is detected as a double click) can vary by operating system and browser, and is often user-configurable. You want to change your events so that you don't have a .click and .dblclick on the same element. http://api.jquery.com/dblclick/

Categories : Javascript

php code allways runs else and not if
You have code like this: if A if B else C That else applies to the if B, NOT the if A. I think you meant this: if A elseif B else C

Categories : PHP

How can I detect if my app runs under IE8 vs IE9 in JavaScript?
Conditional Comments. There are some other alternatives but conditional comments are simple and functional. MSFT provides this information http://msdn.microsoft.com/en-us/library/ms537509(v=vs.85).aspx

Categories : Javascript

JavaScript: Set Interval runs only once?
This is due to the behaviour of floating point arithmetic. Which is explained in this question. The opacity is never actually reaching 0, so the timer is never cleared. The solution is to use toFixed(1) when you are performing your subtraction and addition: var timer = setInterval(function (){ el.style.opacity = (el.style.opacity - 0.1).toFixed(1); if (el.style.opacity == 0) { clearInterval(timer); } }, 40); JSfiddle example is here: http://jsfiddle.net/28XNK/2/

Categories : Javascript

Multiprocessing with python3 only runs once
Don't try to rewrite the whole multiprocessing library again. I think you can use any of multiprocessing.Pool methods depending on your needs - if this is a batch job you can even use the synchronous multiprocessing.Pool.map() - only instead of pushing to input queue, you need to write a generator that yields input to the threads.

Categories : Python

Does combiner runs conditionally
When the map function generate the intermediate result and first sent them to buffer, the partitioning and sorting will start and , if a combiner is specified, it will be invoked at this time. This process is in parallel with the map function. When map function finishes, all the spills on disk will be merged, and combiners will also be invoked at this time too. The buffer threshold is limited by io.sort.spill.percent, during which spills are created. If the number of spills is more than min.num.spills.for.combine, combiner gets invoked on the spills created before writing to disk. So to answer your question: you are right it is the choice a) . Ref : This mail thread.

Categories : Hadoop

CSS runs title instead of HTML
Assuming that you mean the title element within head, one option, if you can, would be to use JavaScript. // set current title to foo document.title = 'foo';

Categories : CSS

Calculator runs first time only
try this its works perfect /* * To change this template, choose Tools | Templates * and open the template in the editor. */ package com.java.util.test; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.HashMap; import javax.swing.JFrame; /** * * @author shreyansh.jogi */ import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.*; public class JavaApplication2 extends JFrame implements ActionListener { /** * */ private static final long serialVersionUID = 1L; JButton num1, num2, num3, num4, num5, num6, num7, num8, num9, num0, add, sub, div, mult, equalto, exit, point, reset; JTextField txtfld; String s = "", ope = ""; int flag = 0; double total1; double

Categories : Java

Counting runs in a string
You can use a combination of itertools.groupby and collections.Counter: >>> from itertools import groupby >>> from collections import Counter >>> strs = 'TTHHTHHTHHHHTTHHHTTT' >>> Counter(k for k, g in groupby(strs)) Counter({'T': 5, 'H': 4}) itertools.groupby groups the item based on a key.(by default key is the items in the iterable itself) >>> from pprint import pprint >>> pprint([(k, list(g)) for k, g in groupby(strs)]) [('T', ['T', 'T']), ('H', ['H', 'H']), ('T', ['T']), ('H', ['H', 'H']), ('T', ['T']), ('H', ['H', 'H', 'H', 'H']), ('T', ['T', 'T']), ('H', ['H', 'H', 'H']), ('T', ['T', 'T', 'T'])] Here first item is the key(k) based on which the items were grouped and list(g) is the group related to that key. As we're

Categories : Python

First iteration for loops & wet/dry runs
A cleaner solution (if I understood the problem correctly) would be to simply ignore lines that contain the same text as the previous one after "You're currently in: ". You are interested in the timestamp of the last line that wasn't ignored under this condition. ignore_if_equal_to = None with open(file_location) as file_object: for each_line in file_object: if "You're currently in: " in each_line: trail = each_line.split("You're currently in: ")[1:] if trail == ignore_if_equal_to: continue recent_statement = eachLine ignore_if_equal_to = trail print recent_statement

Categories : Python

RegisterReceiver runs always or the app must run on background?
Assuming you refer to a BroadcastReceiver. You can use the same intent filters to launch an activity, service or even a single BroadcastReceiver in the manifest like this: <receiver android:name="MyScheduleReceiver" > <intent-filter> <action android:name="***your intent***" /> </intent-filter> </receiver> this example is for a BroadcastReceiver. Also, can you post your code? Here is a nice tutorial about BroadcastReceivers: vogella articles-AndroidBroadcastReceiver

Categories : Android

My Download Servlet runs twice
You make two requests. One by calling builder.sendRequest(null, new RequestCallback() and the other in the callback with status 200 Window.Location.replace(link) Btw i hope this isnt a code that will be deployed. Not handled exceptions Database operations should be done in an own layer I cant see any code convention You should only select the columns u realy need Unnecessary declarations There are many other points, but you should fix this at first and then u will be able to find errors and maintain the code by yourself

Categories : Java



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