Iam using an wcf web service to retrieve value from database ,iam calling it from jquery ajax call,the problem is getPollDetails.ModelMake is null or not an object.
aspx code:
var varType;
var varUrl;
var varData;
var varContentType;
var varDataType;
var varProcessData;
//Generic function to call AXMX/WCF Service
function CallService() {
$.ajax({
type: varType, //GET or POST or PUT or DELETE verb
url: varUrl, // Location of the service
data: varData, //Data sent to server
contentType: varContentType, // content type sent to server
dataType: varDataType, //Expected data format from server
processdata: varProcessData, //True or False
success: function (msg) {//On Successfull service call
ServiceSucceeded(msg);
},
error: alert('not working')// When Service call fails
});
}
//Data Available
function ServiceSucceeded(result) {
$('span[id=lblmakemodels]').text(result.getPollDetails.ModelMake);-->when i keep break point on (result.getPollDetails.ModelMake) value is coming here also.
alert(result.getPollDetails.ModelMake);
}
function PollingDataJSON(selectdata) {
alert(selectdata);
varType = "POST";
varUrl = "../HttpHandler/GetPollingDataService.svc/getPollDetails";
varData = JSON.stringify({
vehicleno: selectdata,
});
varContentType = "application/json; charset=utf-8";
varDataType = "json";
varProcessData = true;
CallService();
}
wcf code:
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
[ServiceBehavior(IncludeExceptionDetailInFaults = true)]
[DataContract]
public class GetPollingDataService : IGetPollingDataService
{
[DataMember]
public string ModelMake;
}
public GetPollingDataService getPollDetails(string vehicleno)
{
if (dr.Read() != null)
{
objdet.ModelMake = dr["YearMake"].ToString();
dr.Close();
return objdet;
}
}
when i keep the break point values is retreiving in objdet.ModelMake.
Iftikar HussainPosted Aug 7, 2013, 3:10 AM
Regards,
Iftikar
ashok kumarPosted Aug 7, 2013, 3:15 AM
ashok kumarPosted Aug 7, 2013, 2:52 AM
Iftikar HussainPosted Aug 7, 2013, 2:46 AM
Regards,
Iftikar
ashok kumarPosted Aug 7, 2013, 2:43 AM
Iftikar HussainPosted Aug 7, 2013, 2:21 AM
public class CarModel
{
public string ModelId {get;set;}
public string ModelMake {get;set;}
}
in your WCF
in your script
Regards,
Iftikar
ashok kumarPosted Aug 7, 2013, 2:16 AM
I need to return multiple values not only "yearmake","Modelid" etc so thats why i returned class objects, and tried to access like object.variable ,Could pls say me is it possible.
Iftikar HussainPosted Aug 7, 2013, 2:12 AM
in javascript
Regards,
Iftikar
ashok kumarPosted Aug 7, 2013, 2:05 AM
I tried Like this Iam getting Undefined in the Box,But value is showing when i debug.
Iftikar HussainPosted Aug 7, 2013, 1:59 AM
Try like this
Regards,
Iftikar
ashok kumarPosted Aug 7, 2013, 1:51 AM
jidhin trPosted Aug 7, 2013, 1:47 AM