Search code examples
javascriptgoogle-closure-library

JSONP send parameters are being modified by the Closure Compiler


I am building a large app using the Google Closure Library. I am getting data from a MongoDB-PHP environment via JSONP. Request go through a load balancing test which determines the most suitable server to get the data from, then returns the corresponding JSON data.

The problem is when I build the application with the closure builder, the parameters of the JSONP.send method modify, so instead of sending what I should send, I am sending random parameters. How can I force the compiler to keep those object property names as I wrote them, without making any changes? thanks


Solution

  • Assuming you are using ADVANCED optimizations, you are running into problems with property renaming. You can read about it here:

    https://developers.google.com/closure/compiler/docs/api-tutorial3

    The easiest thing to do is use SIMPLE optimizations, otherwise you need to build the parameters with quoted properties:

    var params = { 'aParam': 1 };