I need help guys.
I am trying to fetch data from the server which is returning JSON data but I am getting the following error message (in Firefox 48).
Uncaught SyntaxError: Unexpected token <
It seems like the JSON data that is returned is invalid or its not in the expected format.
When I run it in Chrome 52, there is no error message and the data is being returned on the response but it does not run the code inside my function.
My server is returning data in the following JSON format.
[{ "ActionCardId": 1, "ActionCardNumber": "279877", "AccountNo": "2202322179", "ClientName": null, "CellNumber": "0787596971", "TenantName": null, "TenantCellNumber": null, "AddressStandNo": null, "AddressStreet": "43 DELMAS AVENUE", "AddressSuburb": "BOKSBURG", "AddressCity": null, "AddressPortion": null, "AddressEarthNo": null, "AddressPremise": null, "AddressGISKEY": null, "AmountDueTotal": 4080.0, "AmountDue30Day": null, "AmountDueCurrent": null, "AmountDue60Day": null, "ServiceLevy": null, "MeterNumberWater": null, "MeterNumberElectricity": "M22541", "MeterNumberElectricity2": null, "MeterNumberElectricity3": null, "MeterNumberPrePaid": null, "IsPrinted": true, "IsResidential": null, "ActionSuccessful": false, "ActionCardDate": "2016-08-22T00:00:00", "Remarks": null, "UnSuccessfulReason": null, "CaptureContractorId": null, "AddressCombo": ", 43 DELMAS AVENUE, BOKSBURG, , ", "BillCycleName": "120", "ServiceIndicator": null, "WaterReading": null, "WaterReadingDate": null, "ElectricityReading": null, "ElectricityReadingDate": null, "Unit": null, "ActionCardTypeId": 2, "ContractorId": 1, "ActionCardStatusId": 1, "UnSuccessfulActionReasonId": null, "TechnicianId": 1, "AccountInfoId": null, "ServiceDeliveryCentreId": 4, "BillCycleId": 2, "ActionCardType": null, "Contractor": null, "ActionCardStatus": null, "UnSuccessfulActionReason": null, "Technician": null, "AccountInfo": null, "ServiceDeliveryCentre": null, "BillCycle": null, "ActionName": "ED", "DateCreated": "2016-07-06T00:00:00", "DateModified": "2016-08-13T10:24:17.5833635", "CreatedByOnlineUserId": null, "ModifiedByOnlineUserId": "fa93e65d-e4a7-4a0c-91c6-4561e2612f9c", "CreatedByUser": null, "ModifiedByUser": null }, { "ActionCardId": 2, "ActionCardNumber": "279876", "AccountNo": "2200630592", "ClientName": null, "CellNumber": "0787596971", "TenantName": null, "TenantCellNumber": null, "AddressStandNo": null, "AddressStreet": "43 DELMAS AVENUE", "AddressSuburb": "BOKSBURG", "AddressCity": null, "AddressPortion": null, "AddressEarthNo": null, "AddressPremise": null, "AddressGISKEY": null, "AmountDueTotal": 4080.0, "AmountDue30Day": null, "AmountDueCurrent": null, "AmountDue60Day": null, "ServiceLevy": null, "MeterNumberWater": null, "MeterNumberElectricity": "M22541", "MeterNumberElectricity2": null, "MeterNumberElectricity3": null, "MeterNumberPrePaid": null, "IsPrinted": true, "IsResidential": null, "ActionSuccessful": false, "ActionCardDate": "2016-08-22T00:00:00", "Remarks": null, "UnSuccessfulReason": null, "CaptureContractorId": null, "AddressCombo": ", 43 DELMAS AVENUE, BOKSBURG, , ", "BillCycleName": "120", "ServiceIndicator": null, "WaterReading": null, "WaterReadingDate": null, "ElectricityReading": null, "ElectricityReadingDate": null, "Unit": null, "ActionCardTypeId": 2, "ContractorId": 1, "ActionCardStatusId": 1, "UnSuccessfulActionReasonId": null, "TechnicianId": 1, "AccountInfoId": null, "ServiceDeliveryCentreId": 4, "BillCycleId": 2, "ActionCardType": null, "Contractor": null, "ActionCardStatus": null, "UnSuccessfulActionReason": null, "Technician": null, "AccountInfo": null, "ServiceDeliveryCentre": null, "BillCycle": null, "ActionName": "ED", "DateCreated": "2016-07-06T00:00:00", "DateModified": "2016-08-13T10:51:16.575637", "CreatedByOnlineUserId": null, "ModifiedByOnlineUserId": "fa93e65d-e4a7-4a0c-91c6-4561e2612f9c", "CreatedByUser": null, "ModifiedByUser": null }, { "ActionCardId": 3, "ActionCardNumber": "279875", "AccountNo": "2200630306", "ClientName": null, "CellNumber": "0787596971", "TenantName": null, "TenantCellNumber": null, "AddressStandNo": null, "AddressStreet": "43 DELMAS AVENUE", "AddressSuburb": "BOKSBURG", "AddressCity": null, "AddressPortion": null, "AddressEarthNo": null, "AddressPremise": null, "AddressGISKEY": null, "AmountDueTotal": 4080.0, "AmountDue30Day": null, "AmountDueCurrent": null, "AmountDue60Day": null, "ServiceLevy": null, "MeterNumberWater": null, "MeterNumberElectricity": "M22541", "MeterNumberElectricity2": null, "MeterNumberElectricity3": null, "MeterNumberPrePaid": null, "IsPrinted": true, "IsResidential": null, "ActionSuccessful": true, "ActionCardDate": "2016-08-22T00:00:00", "Remarks": null, "UnSuccessfulReason": null, "CaptureContractorId": null, "AddressCombo": ", 43 DELMAS AVENUE, BOKSBURG, , ", "BillCycleName": "120", "ServiceIndicator": null, "WaterReading": null, "WaterReadingDate": null, "ElectricityReading": null, "ElectricityReadingDate": null, "Unit": null, "ActionCardTypeId": 2, "ContractorId": 1, "ActionCardStatusId": 1, "UnSuccessfulActionReasonId": null, "TechnicianId": 1, "AccountInfoId": null, "ServiceDeliveryCentreId": 4, "BillCycleId": 2, "ActionCardType": null, "Contractor": null, "ActionCardStatus": null, "UnSuccessfulActionReason": null, "Technician": null, "AccountInfo": null, "ServiceDeliveryCentre": null, "BillCycle": null, "ActionName": "ED", "DateCreated": "2016-07-06T00:00:00", "DateModified": "2016-08-13T10:51:16.6757162", "CreatedByOnlineUserId": null, "ModifiedByOnlineUserId": "fa93e65d-e4a7-4a0c-91c6-4561e2612f9c", "CreatedByUser": null, "ModifiedByUser": null }]
What could be the issue here?
I am using jsonp because I am using cross domain.
Thank you.
What I have tried:
$("#importDailyJobs").click(function () {
var technicianId = 1;
var serverUrl = "http://localhost:35825/Mobile/ImportDailyReadings"
$.get(serverUrl, { TechnicianId: technicianId }, function (data, status) {
alert("Success");
console.log(data);
}, "jsonp");
});