locked
Unable to get JSONP (Json with padding response) when JSON enabled WCF service is called. RRS feed

  • Question

  • User-1810177356 posted

    We are calling JSON enabled service uning Ajx function $.getJSON(). While calling we are appending callback to the url since we want jsonp response. But WCF service returns json response only and hence $.getJSON() fails to parse that response since it expects JSONP response. We have made all the necessary configuration on WCF web.config file. and proper attributes are also used but still we are not getting proper JSONP response.

    Following is our operation contract

     [OperationContract]
            [WebGet(BodyStyle = WebMessageBodyStyle.WrappedRequest,
                UriTemplate = "/GetData/{token}/{targetID}/{rowID}/{userName}/{requestID}", ResponseFormat = WebMessageFormat.Json)]

            TargetData GetDataJSON( string token,string targetID,string rowID,string userName,string requestID );

    Following is the ajax call

     var JSonRequestLink =http://localhost/AltusMobileWebServices/AltusMobileWebService.svc/json/GetSingleTargetLocationbyTargetID/10f8f867-f815-4fd6-8fa0-1db8e7350214/1/0/principal/0?callback?

      $.getJSON(JSonRequestLink, function (data) {
                   alert(data);

    });

    We get JSON response but call back function is not invoked since getJSON expects JSONP response and hence getting error saying that syntax error ...Invalid lablel.



    Tuesday, January 22, 2013 8:58 AM

Answers

  • User318704987 posted

    I think the problem is that you are not supplying parameter in $.getJSON

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, January 24, 2013 12:27 PM

All replies

  • User-649116597 posted

    Please refer this link,

    http://stackoverflow.com/questions/2887209/what-are-the-differences-between-json-and-jsonp

    Thursday, January 24, 2013 8:16 AM
  • User318704987 posted

    I think the problem is that you are not supplying parameter in $.getJSON

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, January 24, 2013 12:27 PM