ERROR: Microsoft JScript runtime error: Object doesn't support this property or method
here is how the json2 is calling from:
**var json = JSON2.stringify(settings.data);**
i am using WCF service to pull the data and its very simple for the purpose of test and it does returning me the data from wcf service but it fails on json2.js on line number 314-316
// We split the first stage into 4 regexp operations in order to work around
// crippling inefficiencies in IE's and Safari's regexp engines. First we
// replace all backslash pairs with '@' (a non-JSON character). Second, we
// replace all simple value tokens with ']' characters. Third, we delete all
// open brackets that follow a colon or comma or that begin the text. Finally,
// we look to see that the remaining characters are only whitespace or ']' or
// ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval.
if (/^[\],:{}\s]*$/.test(text.replace(/\\["\\\/bfnrtu]/g, '@').
replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']').
replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
here is what i am doing
// *** Generic Service Proxy class that can be used to
// *** call JSON Services generically using jQuery
// *** Depends on JSON2 modified for MS Ajax usage
function serviceProxy(wjOrderServiceURL) {
var _I = this;
this.ServiceURL = wjOrderServiceURL;
// *** Call a wrapped object
this.invoke = function (options) {
// Default settings
var settings = {
serviceMethod: '',
data: null,
callback: null,
error: null,
type: "POST",
processData: false,
contentType: "application/json",
dataType: "text",
bare: false
};
if (options) {
$.extend(settings, options);
}
// *** Convert input data into JSON - REQUIRES Json2.js
var json = JSON2.stringify(settings.data);
// *** The service endpoint URL
var url = _I.ServiceURL + settings.serviceMethod;
debugger
$.ajax({
url: url,
data: json,
type: settings.type,
processData: settings.processData,
contentType: settings.contentType,
timeout: settings.timeout,
error: settings.error,
dataType: settings.dataType,
success:
function (res) {
if (!settings.callback) { return; }
// *** Use json library so we can fix up MS AJAX dates
var result = JSON2.parse(res);
debugger
if (result.ExceptionDetail) {
OnPageError(result.Message);
return;
}
// *** Bare message IS result
if (settings.bare)
{ settings.callback(result); return; }
//http://encosia.com/2009/07/21/simplify-calling-asp-net-ajax-services-from-jquery/
if (result.hasOwnProperty('d'))
{ return settings.callback(result.d); }
else
{ return result; }
// *** Wrapped message contains top level object node
// *** strip it off
// for (var property in result) {
// settings.callback(result[property]);
// break;
// }
}
});
};
}
function GetFederalHolidays() {
$("#dContacts1").empty().html('Searching for Active Contacts...');
ContactServiceProxy.invoke({ serviceMethod: "Holidays",
callback: function (response) {
// ProcessActiveContacts1(response);
debugger
},
error: function (xhr, errorMsg, thrown) {
postErrorAndUnBlockUI(xhr, errorMsg, thrown);
}
});
}
wcf is returning me simple string
public List<string> Holidays()
{
List<string> s = new List<string>();
s.Add("01/01/2010");
s.Add("02/01/2010");
s.Add("03/01/2010");
s.Add("04/01/2010");
s.Add("05/01/2010");
return s;
}
any help what iam doing wrong? i try to change from dataType: text to json but i get the same error above.