Hello everyone,
I am currently developing javascript webcomponents with surveyjs for multi-platform implementation.
Since I'm working with different hosts and urls I'd need to dynamically change the url based on the server I'm on.
For example:
I have the generic API url of a dropdown question: /generic/api/url?param1={question1}¶m2=constant
I need to change that url based on the backend server so for example:
If I'm on x.y.z.w/server1/getSurvey?id=1
, my ChoicesRestfull questions will have the /server1 prefix on their urls: /server1/generic/api/url?param1={question1}¶m2=constant
And this will go for other servers as well:
/server2/generic/api/url?param1={question1}¶m2=constant
/server3/generic/api/url?param1={question1}¶m2=constant
[…]
Now, I know that you can intercept the XMLHttpRequest with:
JavaScriptSurvey.ChoicesRestfull.onBeforeSendRequest = function(sender, options) {
// do stuff here
};
But there's no way to access the processedUrl
variable that contains the already parsed URL with the query parameters already set, I can only access the url
variable from the sender
object. This way I cannot change the url, because what I get still contains the unparsed parameters.
I just wanted to know if I can do this with the already provided Choices widget or I'll have to create a custom widget.
Thank you