5 Replies Latest reply on Jul 5, 2016 10:54 AM by rayedh RSS
    mak Explorer

    Ajax post data into  ContentLoaderFunctions.PostJSON ?

    The following ajax code is used to find closest stations.

     

    jQuery.ajax(

            { type: 'POST',

              url: 'http://api/server/search.php',

             data: { 'apikey': ApiKey, 'apiversion': '3', 'action': "search", 'type':'near', 'lat':'59.91673', 'long': '10.74782', 'distance': '2000', 'limit': '10' },

             success: printJsonResponse,

             dataType: 'json' }

    );

     

    -----------------------------------------------------------------------------

     

    var apiKey = "123";

    var params = {

        url: "http://api/server/search.php" /* STRING */,

        content: {'apikey':apiKey, 'apiversion':'3', 'action': 'search', 'type':'near', 'lat':'59.916', 'long':'10.75', 'distance':'2000', 'limit': '10'} /* JSON */,

        timeout: 60 /* NUMBER */

    };

     

    var result = Resources["ContentLoaderFunctions"].PostJSON(params);

     

    But I get the answer "The API is not valid". Could anyone help me how to convert the above JQuery.ajax code into correct PostJSON params?