Tuesday, August 28, 2012

Passing value from inside of function to a parameter in JavaScript

I have a function that replaces characters from a string



function ratko(a) {
var k = a.toString();
var z = k.replace(/\\,/g, \'], [\');
var s = z.replace(/\\./g, \', \');
var final = \"[[\" + s + \"]]\";
alert(final);
}


What I need is to get the value of final outside the function like this:



var outsideValue = final;


EDIT!!! –


function ratko() gets it\’s value from ajax


success: function (data) {

if (data.success) {

alert(\”Note: This month has \” + data.holidays.length + \” holidays.\”);

praznici = data.holidays;

ratko(praznici);

}

else {

alert(data.ErrorMessage);

}






Rating: 3 out of 5 based on 5 ratings



The post Passing value from inside of function to a parameter in JavaScript appeared first on Javascript ASK.






via Javascript ASK http://javascriptask.phpfogapp.com/passing-value-from-inside-of-function-to-a-parameter-in-javascript.html

No comments:

Post a Comment