Loading a Google Charts example with XMLHttpRequest turns the page white - javascript

We have a page which uses XMLHttpRequests and tries not to reload the page at all. After the user has logged in it should load a chart. Here is the main page: http://pastebin.com/h55Vzuvy
Here is what we are loading as the chart: http://pastebin.com/zDZr3bb6
I realize that the code where the function is called to load chart.php isn't displayed here but it is working properly and simply calls the xmlhttpGet function in the header of the main page.
The page that loads does evaluate Javascript, as I can put an alert and it pops up but the graph simply doesn't load. Any ideas why?
Also, the Chrome JS Debugger says this when I click to load the chart file. I have triple checked to make sure that the div name is being passed to the variables and the error only happens when loading the chart page.
Uncaught TypeError: Cannot set property 'innerHTML' of null
sethtml
callBackFunction
xmlHttpReq.onreadystatechange

Looks good at first glance, but this line:
document.getElementById(div).innerHTML=content;
Looks like it's where you're having the problem. Most likely 'div' (the id which should be 'auth_status' at this point) is not set right or the DOM was modified and busted up the auth_status div.
I'd recommend testing with:
console.log("id: " + div);
on the line right before that (so, line 66). If that shows "auth_status" as the ID like you'd expect, then I'd try typing this in the firebug/chrome js console:
document.getElementById(div)
to make sure it's still in the DOM. Good luck!

Related

TinyMCE plugin creation callback not running until second load

I am attempting to add in a third party plugin to TinyMCE that is built to connect language-tool and TinyMCE. The plugin will load and work properly only after the second time the page is loaded. The plugin is properly created here
tinymce.PluginManager.add('languagetool', function(editor, url) {
and added to the TinyMCE plugin list here
config.plugins = 'languagetool link lists paste';
When loading the page the first time, I receive the following error.
Uncaught TypeError: Cannot set property 'onload' of null
TinyMCE does not load the editor box at all. After switching to a different page and back, the error no longer appears but the TinyMCE editor (with some plugin functionality) is now visible and is able to be used.
Without seeing running code it will be difficult for anyone to give you a specific thought on why this is happening. Any time I see:
Cannot set property 'xxxxxxx' of null
...this typically means that some code assumes a variable has a value when its null. For example I could try to execute:
tinymce.activeEditor.getContent();
...but if there is no active editor then tinymce.activeEditor is null and you can't execute the getContent() on null. In your scenario some part of the code is trying to run the onload method but the object on which that is being called is null.
You need to figure out what line of code is causing that and then figure out why a variable is null when it is expected to be something else.

SharePoint 2013, unable to set property 'control' .load()

I have customized a master page in SP 2013, adding a jquery library(vs:1.11.3) to the .html master page as well as some custom script for pulling in HTML content.
Custom Code reference in master page:
$(document).ready(function() {
$('#sideNavBox').empty().load('https://pageiampullingin.html');
$('#sideNavBox').css('display', 'block');
});
The page I'm pulling in has its own script links that act on the DOM elements for the page I'm pulling in. This code works, even though I'm getting an error:
"Unable to set property 'control' of undefined or null reference".
When I hit F12, occurs under ScriptResource.axd, {Sys.UI.Control ... a.control=this}. I've tried different methods for .load() but still getting this error. Again, HTML is pulled in and script works but can't figure out this error. When I block the .load function, the error goes away. Any help would be appreciated.
This line is causing that error: $('#sideNavBox').empty()
Not sure what you are trying to achieve. Remove the line and check. The error should be gone.
I know this is old but...
He's trying to replace the sharepoint left nav with custom content. I'd try this.
$('#sideNavBox').html("").load('https://pageiampullingin.html');

Click button on webpage via Applescript - Error

I'm trying to click on a webpage item via AppleScript but with no success.
I tried the following code in chrome and safari:
execute "document.getElementById('t-strikethrough').click();"
and
do JavaScript "document.getElementById('t-strikethrough').click();"
In Safari, the first line of code does nothing and the result section of Script Editor says missing value. With Chrome, I get the following error:
Can’t make "document.getElementById('t-strikethrough').click();" into
type specifier
This is included inside tell statements to locate app, window and document.
Without seeing all of your AppleScript code, it's difficult to see exactly what the problem is. You may want to try setting a variable for the URL like this:
set URL of document 1 to "http://www.whatever.com"
do JavaScript "document.getElementById('t-strikethrough').click();" in document 1
Check this post to see the full example . Click Button on Webpage with Applescript/JavaScript

get a php web page to refresh if a session variable is set

I have a web page set up and I'm using PHP, JavaScript, AJAX and jQuery in that page, obviously along with HTML and CSS. I'm using jQuery in the page to hide/show some of the page content dependent on selections made by the user. The page also has a couple of popups that also enable the user to do things with the content in the page (doing things in the database, etc).
Everything works fine apart from when the user does things with one of the popups. When that popup is used, the page doesn’t load properly afterwards. I know the problem has something to do with jQuery, because the page stops loading at the point in the code where the jQuery code actually starts.
Anyway, I know that I can press F5 when the problem discussed above occurs, because when I do that the page re-loads normally (without any sign on previous failure). Therefore, it seems like I need to find a way of refreshing the page automatically in my code, when necessary.
I’ve already set up a session variable that gets set when the popup code is run (as shown below).
$_SESSION[‘appointment_clipboard_updated’] = 1;
I also need to set up code in the page that has the problem, which checks if that session variable is set. If the session variable is set, I need code that actually refreshes the page in the same way as would happen if F5 was pressed.
I have tried the following as a way of refreshing in the problematic page, which doesn’t work:
if (isset( $_SESSION[‘appointment_clipboard_updated’]) && $_SESSION[‘appointment_clipboard_updated’] == 1)
{
unset($_SESSION[‘appointment_clipboard_updated’]);
header(‘Location: /index.php’);
exit();
}
I’ve also tried changing the header call in the code above as follows, but that also didn’t work:
header(‘Refresh: 1; /index.php’);
Therefore, if anyone has a workable solution for this problem, please let me know. Big thanks in advance to anyone who offers any help.
I have already spent time searching the web for a solution and I've also had a good look at what's available on this website, but so far I've not found anything that resolves my problem.
the following is jQuery from the header in my page:
$(document).ready(function()
{
$('input[type="checkbox"]').click(function()
{
if ($(this).attr("value")=="s-a-m")
{
if ($('#s-a-m_checkbox').is(':checked'))
{
$('#s-a-m_textarea').show();
$('#s-a-m_components').show();
}
else
{
$('#s-a-m_textarea').hide();
$('#s-a-m_components').hide();
}
}
});
});
the bit above hides or shows page components as necessary. I'll show the code for actually hiding stuff in my HTML further down.
the bit below is what I use to keep everything hidden until the page finishes loading:
$(window).load(function()
{
$('#hide-until-loaded').fadeIn(50);
);
the next bit is what I use to keep everything hidden until the loading completes. This is simnply a div and all the html/php code that's used to generate page content is kept within it:
<div id='hide-until-loaded' style='display: none;'>
There is also a closer for that div near the bottom of the file, which I haven't shown here.
there are also two other divs that hide specific sections of code (a textarea, plus a few other editable page components). these are both within the 'keep hidden until loaded' div shown above. The divs for hiding/showing showing page components are shown below, although as before I haven't shown there closers
<div id='s-a-m_textarea'>
<div id='s-a-m_components'>
Also, everything worked fine with the jQuery, before I started trying yo use the popup. Also, the popup has been in the page for 2 or 3 years and that always worked without problem, until I introduced the jQuery. therefore, for some strange reason the two parts just cause problems for each other.
Finally, all I want to do is refresh the page, because I know it's problem solved when I can get that working. I can see that by clicking F5 when the problem I'm trying to resolve occurs.

How to stop Google from using a Javascript loaded greeting from being used as meta desciption

I have a Javascript greeting that greets new users with a drop down banner like SO has. It only becomes visible after 3 seconds and when the X is clicked it disappears. Since I have not put meta description tags, on every page Google shows that greeting as the meta data. I dont understand why Google is using this seeing as it is not loaded staight away, will this stop happening if i use meta description?
Should I use Meta desciption? On the upside it might help this problem, but then Google wont be able to dynamically fetch data from the site (which happens to be a forum). It so happens that it is doing this anyway and I dont know why?
Thanks!
My best guess is the text from your greeting is being added to the page (a wordpress plugin?) on the server side as visible (so it appears even if javascript is disabled), hidden by javascript on pageload, then just being shown after 3 seconds (i.e. it is really there already and as such is the first major text google finds).
Try changing your greeting plugin/code to generate the div containing the greeting message after page-load, or at least to append it to the end of the document (or apply style="display:none;" as an inline-style so Google can see it) on the server-side then tweak the js to show it. It would no longer greet visitors with js disabled, but would also allow google to reach your main content without encountering the greeting.
It does this because it's the first readable bit of text found when parsing the DOM. I'm not sure if there is a delay google uses before it saves the page state to its cache but that shouldn't matter. I actually use this 'feature' of google to allow me to manipulate what the site listing says in the search listings. If you want it not to show up just move the code for the message to the bottom of your <body>s node list (i.e. put it just before you close the </body>).
display:none won't do anything it has to be moved so that it's not in the first few readable lines of text when the DOM node tree is parsed.

Categories