Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XHR load local file synchronization #78

Closed
ghost opened this issue Jan 18, 2021 · 7 comments
Closed

XHR load local file synchronization #78

ghost opened this issue Jan 18, 2021 · 7 comments

Comments

@ghost
Copy link

ghost commented Jan 18, 2021

Dear @ALL,
At this moment, when use this plugin, I cannot load local file via XHR synchronization as below:
xhttp.open("GET", filePath, false); xhttp.send(null); var text = xhttp.responseText;
Is this issue?
Thank you so much.

@manish2788
Copy link
Member

@taxuangiao No such issue exists as reported by you. Plugin works fine for synchronous request as well.

@ghost
Copy link
Author

ghost commented Jan 19, 2021

@manish2788 Thanks. However, I retry with synchronous XHR request and It is not OK. But I update to asynchronous XHR request, I could load file content. So please check again.

@manish2788
Copy link
Member

@taxuangiao Can you please share a sample cordova app demonstrating the issue you are facing.

@ghost
Copy link
Author

ghost commented Jan 21, 2021

@manish2788 there are source code to load file
var xhr = new XMLHttpRequest();
xhr.open("GET", "js/test.txt", false);
xhr.send();
var data = xhr.responseText;
if (data) {
alert(data);
} else {
alert("ERROR");
}
the result is show alert "ERROR"

@manish2788
Copy link
Member

@taxuangiao Please go through https://javascript.info/xmlhttprequest to understand how to create an XMLHttpRequest request and get a response. No issue with the plugin.

@ghost
Copy link
Author

ghost commented Jan 21, 2021

@manish2788 , with above code, I tried remove this plugin and build on cordova-ios@4 (UIWebView) and it is OK. I think the plugin not support synchronous XHR request.

@gvanmat
Copy link
Member

gvanmat commented Jan 21, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants