I'm trying to create a JSON RPC server in Zend Framework hosted on IIS. Connections to my server work fine using this example, taken from http://site1/request.html:
<HTML>
<HEAD>
<SCRIPT LANGUAGE="javascript" SRC="js/jquery-1.3.min.js"></SCRIPT>
<SCRIPT LANGUAGE="javascript" SRC="js/json2.js"></SCRIPT>
<SCRIPT LANGUAGE="javascript" SRC="js/jquery.zend.jsonrpc.js"></SCRIPT>
</HEAD>
<BODY>
<script type="text/javascript">
$(document).ready(function(){
var myApi = jQuery.Zend.jsonrpc({url: '/api/1.0/jsonrpc'});
});
</script>
</BODY>
</HTML>
I have two sites hosted locally (on IIS 7.5), and the calls work fine to the RPC Server on the same domain - above the url is given as '/api/1.0/jsonrpc'.
If I change this to the url of a another site, e.g. http://site2/api/1.0/jsonrpc the calls fail.
I belive IIS is disallowing anonymous access for the RPC calls, hence why it works from a call made within the current 'doimain'.
Can anyone tell me how to make IIS play nice and allow these sort of requests?
Looks like this is related to a cookie sent with the request. The domain doesn't match when the response comes back so nothing is returned. Time to rebuild!
Related
I've noticed while I deploy my flutter web project with nginx, after doing a "flutter build web" that if I don't delete the cache the old files are still in my chrome browser. Is there a way to force a refresh for users automatically if I deploy updates?
Every browser does caching and is completely normal when you don't immediately see the changes on the client browser. It does take some time for the browser to realize the code has been changed on the server and needs to update its local cache. And is completely depends on the client browser settings and client's connection speed.
But if your situations demand the client to have an updated version of the website in no time, there is a workaround.
The main.dart.js file is something like this below
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>My Flutter App</title>
</head>
<body>
<script src="main.dart.js" type="application/javascript"></script>
</body>
</html>
In order to force browsers to reload the app each time we want that, add a unique parameter to the main.dart.js script-src (for example a version, though it can be anything, even just a random number after ?). The new index.html will look like:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>My Flutter App</title>
</head>
<body>
<script src="main.dart.js?version=1" type="application/javascript"></script>
</body>
</html>
Cons:
You have to manually add the incremented version number every time you want to deploy. Maybe you can write a script for doing that.
It does still take time if the client has slow internet connection. The problem arises when browsers like Chrome show Lite(cached) version of the website untill internet connection is fast enough.
Previous versions still persist to live on the client's browser till timeout
I read it in many articles that, "it is a good practice to listen for global init event in order to trigger your application logic only after the event has been fired". But I tried to do otherwise still no problem occurs. When I check the network tab all, irrespective of the placement of the code, the core libraries are loaded first. Then the code dependent on libraries is loaded.
I tried searching for my answer but couldn't get a clear answer. I tried to check it using a sample code I wrote. But no success.
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=Edge">
<meta charset="UTF-8">
<title>My Pets</title>
<script id="test"
src="https://sapui5.hana.ondemand.com/resources/sap-ui-core.js"
data-sap-ui-theme="sap_belize"
data-sap-ui-libs="sap.m">
</script>
<script>
var oImage2 = new sap.m.Image({
src: "img/cat_sad.jpg",
decorative: false,
alt: "sad cat"
});
oImage2.placeAt("content");
alert("different_script_tag");
</script>
<script>
sap.ui.getCore().attachInit(function() {
alert("inside_attachinit");
var oImage1 = new sap.m.Image({
src: "img/dog_sad.jpg",
decorative: false,
alt: "sad dog"
});
oImage1.placeAt("content");
});
alert("outside_attachinit");
</script>
</head>
<body id="content" class="sapUiBody">
</body>
</html>
I wish to know, if browser already prioritizes the requests accordingly for us, why we are told to follow this good practice?
It is not only "a good practice", it's absolutely necessary in order to enable asynchronous loading.
Activating asynchronous loading of modules requires listening to the init event. Otherwise, the app will crash because you're trying to access Image from sap.m although that library hasn't been loaded yet:
<script id="sap-ui-bootstrap" src="https://ui5.sap.com/resources/sap-ui-core.js"
data-sap-ui-theme="sap_belize"
data-sap-ui-libs="sap.ui.core, sap.m"
data-sap-ui-async="true"
></script>
<script>
var oImage2 = new sap.m.Image(/*...*/); // Uncaught TypeError: Cannot read property 'Image' of undefined!
</script>
If you're wondering why asynchronous loading is important, compare these two scenarios:
1. Without listening to init (no aync possible):
Dependent libraries and other modules are retrieved sequentially one by one.
It uses sync XHR which is deprecated.
While the app loads, browser often freezes.
Users usually need to wait longer until they see something.
2. With async (listening to init required):
Files are retrieved in parallel asynchronously.
No freezing behavior.
Depending on synchronous XHR is not future-proof and makes the app significantly slower. As UI5 is getting better and better and preparing for further improvements, please keep following best-practices in order to "evolve" together with UI5.
When I load <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>, images on my page get replaced with spam ads of all kinds.
I'm testing bare bones in a guest instance of chrome on my pc.
This is the original code:
<html>
<head>
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
</head>
<body>
<img src="/images/ads/mm-mug-wide.jpg" />
</body>
</html>
These are screen shots of the network log with and without the adsense javascript. By the time I killed it, the network log with adsense showed 455 requests over 35 minutes.
With Adsense Javascript: https://18103791804392046531.googlegroups.com/attach/1841b7c6b6b0b5/adsense-network-log-with-adsense.jpg?part=0.3&view=1&vt=ANaJVrFCJMUV-pol5F7XFKcts8bc50qnvFbazg6PVlZXCOCj7PSJXGBJQkoZaU9AzQcs7xh0VS03Q8-pCS9c9iErGlhHCP3mkSWUMeMumfeQPkKkWpanUDU
Without Adsense Javascript: https://18103791804392046531.googlegroups.com/attach/1841b7c6b6b0b5/adsense-network-log-without-adsense.jpg?part=0.2&view=1&vt=ANaJVrHGcOCztReWJmK09Yr0YpkouhCZwxFzmmjfRfk2wyB0Rr9vb30Hl7SkanKF06LcCCxDvElQx4tB_ZQYRxB-96zOY8gXEp_IjL6q6pOzlsSuA4-nQZ8
UPDATE:
It only seems to do it if the word 'ad' or 'ads' ('header' was not a match) appear in the src. If the class is 'ad', it starts loading the spam resources but does not replace the image or continue on indefinitely.
The DNS on my router had been altered to point to a malicious DNS that was rerouting things such as google adsense.
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<script>
(adsbygoogle = window.adsbygoogle || []).push({
google_ad_client: "ca-pub-6483687610557857",
enable_page_level_ads: true
});
</script>
I have a question regarding the embedding of a GWT application.
The problem concerns getting the address of the client, and match it to the ip in the tag's src attribute. So the structure is Host html page (hosted on server a), embedding a gwt application hosted on server b.
<!DOCTYPE HTML>
<html dir="ltr" lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Embedding gwt app</title>
<script type="text/javascript" src="http://192.168.0.1:8080/myapp/myapp.nocache.js?rootpanel=divone"></script>
</head>
<body>
<div id="divone" style="width:100px;height:100px;"></div>
</body>
</html>
What we have tried before is get the host path by using GWT.getHostPageBaseURL(), but this returns the host page's ip (we expected this..)
Are we trying to achieve something impossible? considering that the script file gets downloaded first, and then the onModuleLoad gets called when the script is ready on the client.
You can make a RPC request to the server side, and the server can do the following to get the client's IP: getThreadLocalRequest().getRemoteAddr();
Or if you don't want to make a request and want to do the work on the client side, you can make a GWT native JS method and try one of the suggestions from this stackoverflow post: How to get client's IP address using javascript only?
I have an oscommerce shopping cart site and I'm trying to set up an automatic redirect with 30-second time-delay from one product page to another product page, and include a message like "this prod. is now replaced by [new catalogue number]. You will be automatically redirected." How do I get into the raw HTML/PHP coding for each product so I can put a redirect meta-tag or javascript coding in? Note: I only want to set up the redirect for a handful of product pages (not all products currently on the site).
<html>
<head>
<script type="text/javascript">
<!--
function delayer(){
window.location = "productpage.php"
}
//-->
</script>
</head>
<body onLoad="setTimeout('delayer()', 5000)">
<h2>Prepare to be redirected!</h2>
<p>This page is a time delay redirect, please update your bookmarks to our new
location!</p>
</body>
</html>
you can use Js redirect look like above
check from here > http://jsfiddle.net/JnUVF/