Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
sonic bed head
Dec 18, 2003

this is naturual, baby!

rotor posted:

I've always been surprised that they're not more popular.

They are IE/Windows only AFAIK.

Adbot
ADBOT LOVES YOU

sonic bed head
Dec 18, 2003

this is naturual, baby!

Sock on a Fish posted:

I've got a really simple call to a really simple Prototype function that appears to be timing out after about five minutes or so:
code:
	<script type="text/javascript" charset="utf-8">
		new Ajax.PeriodicalUpdater('log', '$someurl',
		  {
		    method: 'get',
		    frequency: 1,
		  });
	</script>
The script is supposed to give feedback by automatically updating the page from a log file that's exposed on a web server. Is this timeout I'm seeing just something that the browser does if it sees some Javascript that's kicking off every second and not producing any results? I didn't read about any kind of default timeout in the docs, and Google doesn't reveal anything useful.


That's a hell of a lot of AJAX calls without a decay option. I don't know how fast your server can respond, but I'm pretty sure that one open AJAX call/second is screwing something up. I would say at least add a decay of 2 or 3 and see what happens.

Also, are you sure that the log file is changing in the interval where you see a timeout?

sonic bed head
Dec 18, 2003

this is naturual, baby!

Sock on a Fish posted:

I think the timeout occurs during a period when the log isn't being updated. The first step in the log reflects the beginning of a tarball unpack, and depending on load that can take from 1-12 minutes.

The server can respond to this load just fine. It's an internal app that at most 3-4 people are going to be using at once, and the cluster it's on handles thousands of requests per second.

What do you mean by timeout? Is the div id "log" not changing? Are you getting a javascript error? Or are you falling into the failure side of the AJAX Request?

sonic bed head
Dec 18, 2003

this is naturual, baby!
Does anyone know why 3rd party JS libraries never throw any errors? I just spent 4 hours today trying to figure out what I had done wrong after adding Jawr to my web app and the problem was that Nick Stakenburg's Starbox plugin doesn't throw an error when there's something wrong with the image url. It just completely silently fails and doesn't try to create anything.

I've seen this problem in Prototype, JQuery and ExtJS, even in the debug versions. A lot of problems could be solved much easier if informative errors were thrown. I do it in my own code, is this not a best practice?

sonic bed head
Dec 18, 2003

this is naturual, baby!

Kekekela posted:

JSLint gives me a "Bad escapement" message on the following line, I'm guessing its something with that which follows the backslash but I suck at regex and can't get it cleaned up, halp:

code:
var regex = new RegExp("(?=\.(xls|xlsx))");

Why on earth are you using the RegExp constructor? Why not...

code:
var regex = /(?=\.(xls|xlsx))/;
?

sonic bed head
Dec 18, 2003

this is naturual, baby!

argz posted:


The solution here is to do an image check. Unfortunately, I'm a javascript idiot and I've gotten stuck on this problem while trying to solve it different ways. The one I _thought_ would be successful was most certainly not, that was using a global var to set and test true/false.


Sadly I'm pretty sure that javascript in a browser does not give you access to MIME types of the Image() object. Maybe you can make an XHR get the image and check the response headers, but I think that might be a lot of work for this problem.

sonic bed head
Dec 18, 2003

this is naturual, baby!

diadem posted:

Thank you so much. This bug was a huge pain.

For some reason, spaces weren't cutting it, but characters worked fine. A slightly modified version of your last suggestion fixed the issue.

A non breaking space would work there too  .

Apparently you can't type & nbsp ; here, let me try it in a code block

code:
&nbsp;

sonic bed head fucked around with this message at 20:38 on May 7, 2009

sonic bed head
Dec 18, 2003

this is naturual, baby!

FateFree posted:

Thanks alot lumpy I appreciate it. It works fine in IE but not in FF so im looking into that, but otherwise does just what I wanted.

edit: firefox wanted .textContent instead of innerText

.value should work in both.

sonic bed head
Dec 18, 2003

this is naturual, baby!

FateFree posted:

Eh that didnt work for either, I think because its not a form field, rather just text.

Oops, I completely misread that code. I thought you were trying to get what was inside the form field.

sonic bed head
Dec 18, 2003

this is naturual, baby!
Does anyone know of a multiple select javascript code that works with Prototype JS core? I don't want to use any other add on libraries like livepipe and I don't particularly want to roll my own.

sonic bed head
Dec 18, 2003

this is naturual, baby!
I am trying to write some animation javascript code that will make it look like there was suddenly gravity and every element is falling to the bottom of the page. I have no idea where to start with this. I've tried using prototype's absolutize on all of the elements in the body of the page, but that doesn't work. Can anyone give me any advice on where to start? I have no idea of 2D physics but I don't really know where to learn anything. Thanks.

sonic bed head
Dec 18, 2003

this is naturual, baby!

Nigglypuff posted:

You might start by viewing the source of this.


savetheclocktower posted:

Also, Someone ported the Box2D physics engine to JavaScript.

Thank you both! That's exactly what I needed. The google gravity thing actually uses box2d so it's a good practical example.

sonic bed head
Dec 18, 2003

this is naturual, baby!

rt4 posted:

I'm trying to keep track of the URL of a frame on my page. Is it possible to do this with JavaScript?

php:
<?
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
<html>
    <head>
        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script>
        <script type="text/javascript">
            $(document).ready(function() {
                alert($("#inside").toString());
            });
        </script>
    </head>
    <frameset cols="100%" noresize="noresize">
        <frame id="inside" src="content.php">
    </frameset>
</html>
?>
I'm expecting toString() to tell me what's available in that object, but I just keep getting [Object object]
All I really want is the URL. What should I be doing instead?

If you want to get the URL after a change in the src, to make it cross browser compatible, I think you have to use DOM methods, not jQuery methods. Try this:
code:
window.frames[1].location.href;
http://stackoverflow.com/questions/549759/get-frame-source-with-jquery-after-the-source-has-changed

sonic bed head
Dec 18, 2003

this is naturual, baby!

subx posted:

Can someone point me to a good reference of how javascript "objects" actually work? Coming from normal programming languages trying to work with javascript objects is just flat out loving confusing.

I am trying to store some data from an XML as an array of objects, but I can't seem to retrieve the data from those objects.

Say my array is Names with FirstName and LastName properties:

In Firebug I can view Names[0] and it shows me [ Object { FirstName="John", LastName="Smith" } ], which seems like exactly what I wanted. But then if I try to reference Names[0].FirstName it just returns "undefined" - what am I missing here that's probably obvious?

Also is there a difference between:
"FirstName": $(this).find('FirstName').text(),
and
FirstName: $(this).find('FirstName').text(),
(with no quotes)

For the first question - What language is the "normal" language you are coming from? It might help if I can explain in those terms, but the misunderstanding here is straightforward. Names[0] is an Array, not an Object. It is an Array of one item, as per what you've copied from firebug. Try Names[0][0].FirstName, and that should be what you're looking for.

A Javascript array is just a HashMap in Java, an associative array in PHP, a dict in Python.

Second question - In javascript, no, there is no difference. The reason that quotes are sometimes used is because there is a data serialization format called JSON (Javascript Object Notation), which requires the keys of an object to be quoted. Javascript interpreters interpret them in the same way, but if you have a key with a keyword in it, you need to use quotes.

For example {"for":"you"} will not produce a syntax error, but {for:"you"} will.

sonic bed head
Dec 18, 2003

this is naturual, baby!

subx posted:

I think it was mostly just the tutorials that were confusing me. Thanks for clearing up the quotes thing - I didn't notice any difference when I changed them in code, but I wasn't sure if it changed how they were being referenced or something like that.

And I haven't done much Java/Python, mostly come from C++/C#. I had to mess with PHP at my previous job a bit and prefer to forget as much of it as possible, good lord is that a mess of a language.

I'm pretty sure it's called a dictionary in C# too. You can think about it as a basic hashtable [String -> Object].

Adbot
ADBOT LOVES YOU

sonic bed head
Dec 18, 2003

this is naturual, baby!

Munkeymon posted:


Oops, drat typo. Yes, Object, not array. They are deceivingly similar.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply