从另一个函数向函数内的Object添加值

时间:2017-10-26 02:50:57

标签: javascript arrays object

我希望从另一个对象的方法更新chaseObj中的值。请告知,谢谢!

var s, searchUts;
var getValue = '';
var generateObject = function() {
  var chaseObj = {
    "timeFilters" : getValue
  };
  return chaseObj;
};

searchUts = s = {
  createValue: function() {
    var x = 10;
    var y = 20;
    getValue = x + y; //append this value to chaseObj inside the generateObject
  },
  postToBackEnd: function() {
  var chaseObj = generateObj();
    $.ajax({
    url: localhost:8080/site/home,
    data:JSON.stringify(chaseObj) //chaseObj is not updated with new value here

    })
  }

};

1 个答案:

答案 0 :(得分:2)

不清楚你想要什么,但这是你想要的结果吗?



decimal i = 0;   
string s = "108";  
bool isNumeric = decimal.TryParse(s, out i);

if(isNumeric) //Your condition.
else //Your condition.