views:

53

answers:

1

Hi

I need to extract this line of code from a script i am retrieving via ajax..

this line new Date(2010, 10 - 1, 31, 23, 59, 59) from

jQuery(function () { jQuery('#dealCountdown').countdown({ 
until: new Date(2010, 10 - 1, 31, 23, 59, 59), 
serverSync: serverTime, 
timezone: +11, 
compact: true, 
format: 'HMS', 
expiryUrl: BASE, 
layout: '

Is it possible to do this with jquery. The jquery selector won't let me manipulate script tags.

Any help would be greatly appreciated.

A: 

Use javascript's native function String.match:

importantline = "" + ajax_data.match(/until:\s.*,/);
importantline = importantline.replace(/^until:|,$/gi, "");

importantline should have the string you need

I added a jsfiddle to make clear it works: http://jsfiddle.net/elektronikLexikon/3eZAf/

elektronikLexikon
awesome.. i've tried it.. it comes back with until: new Date(2010,followed by importantline.replace is not a function for the second line.. im assuming something is up with the comma?
Alessandro
this importantline = responseText.match(/until:\s.*,/);gives me "until: new Date(2010, 10 - 1, 31, 23, 59, 59),"
Alessandro
oh, my fault... the `?` is wrong here. But does the replace function work now?
elektronikLexikon
now I know what is wrong: the first function does not return a String, so just put a `"" +` before the function call to make it a string (I'll edit it).
elektronikLexikon
awesome! thank you so much!
Alessandro