I want to load a html code into a webview. But the html code has several other external resources. for example in the html code I have :
<script type="text/javascript" src="//cdn3.example.com/example.js"></script>
but it seems that 'example.js' is not executed when rendering the webview.
Is it possible to achieve that ? Thank you
I have similar issue, webview loaded from file:// and won't load external resources... cors set to * on the server side too.
So digging into it further, seems my problem was I used custom ssl certs on server side and android couldn't verify the server authenticity, and so requests were being cancelled. (adding intermediate certs to app would help)
alternately
You can override webclient's shouldInterceptRequest and fetch the external scripts yourself, returning the request from which webview will draw data (make sure you don't fetch during the shouldInterceptRequest call or it will be slooooooow sequentially fetching resources; instead, return a request's subclass and start fetching data async, so by time call to getData comes you already have what you need... search so for async shouldInterceptRequest for help with that).
I have loaded my express app on a server (I used heroku). When I test my app locally it works fine but when I load the page on the web it gives me a net::ERR_BLOCKED_BY_CLIENT saying that it is not able to load a JS file that I define in the HTML page:
<script src="./index.js"></script>
If I try to go to: http://<my-page>/index.js it is able to load the file successfully.
Why this doesn't work?
(If you need more information tell me what I need to add)
I finally solved my problem. There was a problem with the Avira Chrome extension that was blocking the file from loading. I simply added my page to the whitelist and it started working as supposed.
In a page that I work with, we load content from an external server from a provided dynamically created javascript file.
In one of the sections of the document that displays header content, we have the sample line:
<script type="text/javascript" src="externalScriptLocation"></script>
The problem is that when the external script location is down (it could be a 404, but in this case it's actually a 503 - service not available), most of the page's functionality appears to work but the page is not able to properly submit data.
Is there a way I can wrap this with a try/catch or something similar so that failure to load this bit of javascript (which is for a header element that, while it should be there, shouldn't cause these issues!) so that the site can function normally?
If it matters, the server side language is Java with Java Server Pages as the view.
I'm using Netbeans 7.3.1, and usually I can successfully debug PHP files using Xdebug. However, that's only if my site project is structured in such a way that the site is generated from PHP code right off the bat.
Right now I have a site which is mostly made from HTML files. The HTML static, not generated by PHP. The only PHP file in the project is called phphandler.php. I need to debug that PHP file, but it only runs in response to a Javascript/jQuery call from within the HTML files that looks like this:
$.post(siteURL + 'jsonhandler.php', {
JSON: JSON.stringify(data)
}, processResult, "json");
On the PHP side, it processes the JSON request from $_POST
$Array = json_decode(stripslashes($_POST['JSON']), true);
When I run the debugger from within JSON, it opens Chrome and loads my site, starting with index.html, but the debugger never opens jsonhandler.php. I can go through all the links and navigate through my site, and it will get all the JSON data it needs from jsonhandler.php, but the debugger remains uninvolved.
Can I debug through jsonhandler.php when the Javascript sends it a request via $_POST, and if so, how?
Update: I've discovered that I can debug jsonhandler.php using the Debug File function, but this has serious drawbacks, namely that I can't create a situation in which jsonhandler.php is receiving JSON data as constructed by the rest of the site. I can manually force in some hand made test JSON data, but then that seriously inhibits my ability to discover what the system is doing as a whole.
Anyway, for me this is another indicator that the debugging environment is configured correctly, it's just a matter of if and how the debugger can listen for the right events.
What I normally do is putting break points. Try putting breakpoints to the PHP code that receives the request (or that you want to debug) in the jsonhanler.php file and them run in debug mode, navigate through your site and send the request, the debugger should open Netbeans and take you to the line where you left the breakpoint. From there you can now go line by line or jump into functions.
You can try printing the $Array received in the php file by print_r($Array) followed by an exit() which might stop the process in the php file and show you the result coming in the php file. This might allow you to see as to what the php file is getting when it is loaded in the $Array. Or else if its an ajax request you can print the response in the console by console.log(response). I hope it helps.
I recently responded to a similar question here: https://stackoverflow.com/a/19636910/212076
Basically, you need to add a query parameter within your JSON to trigger the debugger:
XDEBUG_SESSION_START=netbeans-xdebug
If the data is being obtained directly from a HTML Form, then include a hidden field like so:
<input type="hidden" name="XDEBUG_SESSION_START" value="netbeans-xdebug" />
I have some Javascript (initially CoffeeScript) code that uses data from the database. I create the data array with .erb, then do the code with .coffee, and finally use the .js. Fairly standard stuff. The problem is that the javascript served to the browser is cached and never refreshes, even after a server restart or assets:clean.
To get the javascript to refresh I have to delete the tmp folder contents and start the server.
Q1. How can I make the javascript refresh on every request? I tried to inline the code using Coffeebeans to render a file with the code but the code appears html encoded.
Q2. Will this even work on Heroku? (it only accepts precompiled assets)