In my application, Asp web service returns JSON with object name called 'd' so I access that 'd' object the in the application as follows,
GetBranchOrRegionDataSourceSuccess: function (result, status, init) {
"use strict";
var regions = JSON.parse(result.d);
}
I called this function inside the Ajax success call.
Now the problem is I have Jquery function called searchLocations, Inside that function, I need to call this function. and need to pass the parameters.
I tried like this,
var jsonResult = JSON.stringify({'d':result});
this.GetBranchOrRegionDataSourceSuccess(jsonResult,"Success", true); //here I need to call the function
this is my complete function.
function searchName(prov,tree) {
var result = [];
let searchKey = new RegExp(prov, "i");
var objects = JSON.parse(json);
for (obj of objects) {
if (obj.Name.match(searchKey)) {
result.push(obj);
} else {
var toAdd = {"Id": obj.Id, "Name": obj.Name, "Branches": []};
for (branch of obj.Branches) {
if (branch.Name.match(searchKey)) {
toAdd.Branches.push(branch);
}
}
if (toAdd.Branches.length) {
result.push(toAdd);
}
}
}
var jsonResult = JSON.stringify({'d':result});
this.GetBranchOrRegionDataSourceSuccess(jsonResult,"Success", true); //here I need to call the function
}
But it makes error inside GetBranchOrRegionDataSourceSuccess on this line var regions = JSON.parse(result.d); How can I pass the result with 'd' object name

RegExp.prototype.test()is faster thanString.prototype.match()if you're just checkingmatchfunctions withtest()?if(searchKey.test(branch.Name))