Click here to Skip to main content
       

JavaScript

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page  Show 
AnswerRe: How to Add Days in Javascript Date ObjectprofessionalDennis E White22 May '13 - 4:39 
Can you give an example of your code that isn't working?? I tried the following and it all appears to be working just fine.
 
http://jsfiddle.net/SrVvn/[^]
as if the facebook, twitter and message boards weren't enough - blogged

AnswerRe: How to Add Days in Javascript Date ObjectmemberNiral Soni23 May '13 - 1:23 
Hi Robymon,
 
The example you have given is incorrect.
 
Adding 12 days to 20-02-2013 will not give result as 01-03-2013, but will give 04-03-2013
 
The solutions given by "Richard Deeming" and "Dennis E White" are correct.
Thanks & Regards,
Niral Soni

Questionfunction for split a complex stringgroupmhd.sbt21 May '13 - 7:06 
hi to all
i have a string with this format
x=numbery=datez=number...
for example of this string can be :
x=123y=2013/02/01z=12345p=111
i want a function that get me this
x=123
y=2013/02/01
z=12345
p=111
 
how can i do this?
note to this point that my string can not be change and add extra character to this string
thanks in advance
AnswerRe: function for split a complex stringmemberryanb3121 May '13 - 10:30 
There is usually many ways to do string manipulation but one way would be to split on the = and then you'll have the rightmost character to be the starting of your next string. You'll have to put in a case for the first one.
 
Or, just loop through each character and process.
There are only 10 types of people in the world, those who understand binary and those who don't.

AnswerRe: function for split a complex stringprofessionalDennis E White22 May '13 - 4:53 
you have to define what are the valid characters that can be on the left hand side of the '=' sign. in other words can you have something like the following?
 
pa1n=1234h1nd=4321gr33d=6789
 
pa1n=1234
h1nd=4321
gr33d=6789
 
that gets a lot more difficult vs if you only allow stuff on the left to be alpha characters and then stuff on the right to be numeric and special characters.
 
sounds like a homework question from a programming class.
as if the facebook, twitter and message boards weren't enough - blogged

AnswerRe: function for split a complex stringmemberNiral Soni23 May '13 - 2:36 
function splitString(myStr) {
    var regex = new RegExp(/[a-z]+[0-9]*[a-z]*=/ig);
    var keyPairs = myStr.match(regex).join('').split('=');
    var valuePairs = myStr.split(regex);
    document.write('======== Start ==========<br/>');
    document.write('INPUT:  ' + myStr + '<br/>');
    
    var map = {};
    for(var i = 0; i < keyPairs.length - 1; i++) {
        map[keyPairs[i]] = valuePairs[i+1];
    }
    for(key in map) {
        document.write(key + ' = ' + map[key] + '<br/>');
    }
    document.write('======== End ==========<br/><br/>');
}
 
splitString('x=123y=2013/02/01z=12345p=111');
splitString('pa1n=1234h1nd=4321gr33d=6789');
Thanks & Regards,
Niral Soni

QuestionReading XML - success being ignored [modified]memberJohn Simmons / outlaw programmer21 May '13 - 1:01 
I have the following code. The problem is that the xml file is being read (it's displayed in FireBug's Console tab), but the success code is not being executed (I can't step through it in the debugger). What am I doing wrong?
 
$.ajax(
{
	type: "GET",
	url: _cfgDataFile,
	dataType: "xml",
	success: function(xml)
	{
		var configNodes = $(xml).find('Config');
		parseConfigNodes(configNodes);
		var imageNodes = $(xml).find('Images');
		parseImages(imageNodes);
		var dataNodes = $(xml).find('Data');
		parseData(dataNodes);
	}
});
 
(I'm using FireFox/Firebug for debugging.)
 
EDIT =====================================
 
I added code to get any error that might be happening, and this is what was returned:
 
[Exception... "Failure" nsresult: "0x80004005 (NS_ERROR_FAILURE)" location: "JS frame :: http://localhost:1437/testwebsite/Scripts/jquery-2.0.0.js :: .send :: line 7713" data: no]
 
It turns out that the problem is actually in FireFox/FireBug. In IE, the code works fine. The world is now officially inside out because FireFox has now managed to out-suck IE.
".45 ACP - because shooting twice is just silly" - JSOP, 2010
-----
You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
-----
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997


modified 3 days ago.

AnswerRe: Reading XML - success being ignoredprofessionalDennis E White21 May '13 - 4:49 
John Simmons / outlaw programmer wrote:
It turns out that the problem is actually in FireFox/FireBug. In IE, the code works fine. The world is now officially inside out because FireFox has now managed to out-suck IE.

Have you tried this in Chrome?? I am a bigger fan of trusting V8 vs the firefox or IE javascript engines.
 
At first glance it doesn't look like you are doing anything wrong. I don't see which domain you are heading to and where you are starting from. Typically that error message comes when you are doing cross-domain stuff and most security settings prevent this from happening.
as if the facebook, twitter and message boards weren't enough - blogged

GeneralRe: Reading XML - success being ignoredmemberJohn Simmons / outlaw programmer21 May '13 - 5:00 
The file I'm trying to load is in the same folder as the script. Domains shouldn't be an issue (as far as I know).
".45 ACP - because shooting twice is just silly" - JSOP, 2010
-----
You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
-----
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997

GeneralRe: Reading XML - success being ignoredprofessionalDennis E White21 May '13 - 5:13 
stumbled across the following:
 
http://www.fleegix.org/articles/2006/10/21/xmlhttprequest-and-0x80004005-ns_error_failure-error[^]
 
and also...
 
http://helpful.knobs-dials.com/index.php/0x80004005_(NS_ERROR_FAILURE)_and_other_firefox_errors[^]
 
Quote:
If you are using firebug, you should be aware that there are older versions that did not handle XHR in frames well. Firebug would be the sole cause of the last mentioned error.

Any luck with Chrome??
as if the facebook, twitter and message boards weren't enough - blogged

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   


Advertise | Privacy | Mobile
Web01 | 2.6.130523.1 | Last Updated 24 May 2013
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid