AngularJS & PrerenderIO, prerenderReady isn't working - javascript

I'm setting the prerenderReady flag in my html (inline)
<script> console.log(Date()); window.prerenderReady = false; </script>
and setting it to true in my angular controller upon $http get success like this:
Post.getAll($stateParams.order, $stateParams.type, 10)
.success(function(response) {
Post.setPosts(response.data);
vm.nextUrl = response.next_page_url;
vm.loading = false;
$window.prerenderReady = true;
console.log(Date());
console.log($window.prerenderReady);
});
the difference between the inline date() and the success of the request is 3secs
nevertheless the prerender server reaches over 11500ms gets timed out and renders only the page's header.

I removed the comment from prerender logger and found out prerender had a problem with socket.io
I didn't knew what could be the problem since I am running prerender server and Socket.io server from different nodes and on different ports.
after trying to upgrade phantomjs from 1.9 to 2.0 with no avail
miraculously I tried replacing the socket.io cdn link in my index.html file
with inline script.
Now the pages are rendered perfectly :)

Related

Access is denied error in signalr script while using iframes in IE

I am rendering report inside an iframe and their domains are not same. While rendering I am getting 'Access is denied' error in IE. Works fine in other browers.
Jquery version: 1.10.2
Signalr version: 2.1.2
Note: Tried by upgrading signalr to 2.2.2 also. It is not working.
//Signalr scripts goes here
<script>
$(document.ready(function () {
var response = $.connection.signalrHub;
response.client.connection = function () {
//connection
};
SJ.iwc.SignalR.start();
});
</script>
Solution tried:
$.connection.hub.start({ transport: ['webSockets', 'serverSentEvents', 'longPolling'] });
Tried by adding this inside document.ready but not working.
Anyone faced this issue ? Is there is any work around for this ?
Please follow the following steps in your sample project.
1. Try to upgrade to jQuery latest version.
2. Try to set the cross domain support using $.support.cors = true.

Loading external file via $.get often not returning response, even that response code is 200

I have a website running on Azure. In there, I'm playing with Knockout.JS components and custom loaders. I've used a very simple example from KO documentation found here:
(A component loader that loads external files using custom code)
http://knockoutjs.com/documentation/component-loaders.html#custom-component-loader
// loader helper
var templateFromUrlLoader = {
loadTemplate: function(name, templateConfig, callback) {
if (templateConfig.url) {
var today = new Date();
var fullUrl = templateConfig.url + "?v=" + today.getTime();
$.get(fullUrl, function(markupString) {
ko.components.defaultLoader.loadTemplate(name, markupString, callback);
});
} else {
callback(null);
}
}
};
// component is registered
ko.components.register('postcode-lookup', {
viewModel: function() {
// component js
},
template: {
url: 'https://www.purplebricks.com/content/lib/component-postcode-lookup/dist/component/templates/postcode-lookup.html'
}
});
ko.components.loaders.unshift(templateFromUrlLoader);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/knockout/3.4.0/knockout-min.js"></script>
Now, locally, everything works perfectly, each time a page gets refreshed, the component template is fetched:
and the preview of the response is here:
The problem arises when the page is deployed to staging/live production. It will work for every person just fine the first time, but as soon as you refresh the page, the probability of template returning blank response is very very high = almost 90%. It is clearly cached, the response code becomes 304 not modified, but the response is blank. I've tried adding a query string that adds a timestamp to it - it made almost 0 difference. Now I have a 200 status code, but the time of the request goes into pending and seems to last forever:
It almost feels like Azure is caching this incorrectly, perhaps DNS issues?
This appears to be down to an incorrectly set gzip header, try adding the following to your route config to prevent ASP.NET MVC from processing the static content:
routes.IgnoreRoute("Content/{*pathInfo}");

Rails js-routes: get path

In my rails app I'm trying to make a transition link in my javascript file with help of js-routes gem
$.get(Routes.pay_account_path(self.tour.ID(), {format: 'html'}), function () {
return true;
});
This code seems correct, but there is no transition to path when I click on the button. In browser inspector network I see that http://example.dev/account/38469212-6116-91B2-591C-91D30FBDD6B6/pay.html response is OK

casperjs testing an internal site

I am trying to run a casper test for an internal site. Its running on pre-production environment, the code so far is
var casper = require('casper').create({
verbose: true,
loglevel:"debug"
});
// listening to a custom event
casper.on('page.loaded', function() {
this.echo('The page title is ' + this.getTitle());
this.echo('value is: '+ this.getElementAttribute
('input[id="edit-capture-amount"]',
'value'));
});
casper.start('https://preprod.uk.systemtest.com', function() {
this.echo(this.getTitle());
this.capture('frontpage.png');
// emitting a custom event
this.emit('age.loaded.loaded');
});
casper.run();
as you can see its not much but my problem is the address is not reachable. The capture also shows a blank page. Not sure what i am doing wrong. I have checked the code with cnn and google urls, the title and screen capture works fine. Not sure how to make it work for an internal site.
I had the exact same problem. In my browser I could resolve the url, but capserjs could not. All I got was about::blank for a web page.
Adding the --ignore-ssl-errors=yes worked like a charm!
casperjs mytestjs //didn't work
capserjs --ignore-ssl-errors=yes mytestjs //worked perfect!
Just to be sure.
Can you reach preprod.uk.systemtest.com from the computer on which casper runs ? For example with a ping or wget.
Is there any proxy between your computer and the preprod server ? Or is your system configured to pass through a proxy that should not be used for the preprod server ?
The casper code seems to be ok.
I know this should be a comment but I don't have enough reputation to post a comment.
As far as CasperJs tests are run in localhost, for testing a custom domain/subdomain/host, some headers need to be defined.
I experienced some problems when passing only the HOST header, for instance, snapshots were not taken properly.
I added 2 more headers and now my tests run properly:
casper.on('started', function () {
var testHost = 'preprod.uk.systemtest.com';
this.page.customHeaders = {
'HOST': testHost,
'HTTP_HOST': testHost,
'SERVER_NAME': testHost
};
});
var testing_url: 'http://localhost:8000/app_test.php';
casper.start(_testing_url, function() {
this.echo('I am using symfony, so this should have to show the homepage for the domain: preprod.uk.systemtest.com');
this.echo('An the snapshot is also working');
this.capture('casper_capture.png');
}

Javascript error in ASP.NET caused by changing from Cassini development server to IIS 7.5 express

I have recently changed from using the cassini development server to IIS 7.5 express, and have found that on some pages my javascript is throwing 'Object doesn't support this property or method' exceptions.
All the pages share the same masterpage which loads all the plugins, and when debugging in the browser the scripts seem to be available.
One particular example is
$(document).ready(function () {
var dlg = $('#<%=PanelAddToList.ClientID%>').dialog({ autoOpen: false, modal: true });
// $('#<%=PanelAddToList.ClientID%> .List-Add').click(function () { __doPostBack('<%=BtnAddToList.UniqueID%>', ''); });
$('#<%=PanelAddToList.ClientID%> .dialog-button-cancel').click(function () { $('#<%=PanelAddToList.ClientID%>').dialog('close'); });
dlg.parent().appendTo(jQuery("form:first"));
});
This is contained in a usercontrol which has PanelAddToList in it. This control works on some pages using IIS but on others it will cause an exception on the 'var dlg =' ... line.
If i switch back to using cassini it all works normally.
Any help would be appreciated, thank you
check if jquery load before not because this type of error occur when they did not find any object.
i think in you case dialog have some error, page can't find dialog method or arguments..

Categories