I copied a script that works on one server to another but it doesn't work on that server. To troubleshoot it I created a test file with just this code
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<script>
ShowThePopout();
function ShowThePopout() {
console.log('show box');
$.post( "sidebox_ajax_test.php", { show_cart: true })
.done(function( data ) {
console.log('good result');
});
}
</script>
The sidebox_ajax_test.php file just has this
<?php
echo 'done';
I uploaded the two files to both servers. When the test page is visited, on the first server the console shows
show box
XHRPOSThttp:.../sidebox_ajax_test.php
good result
On the second server it shows
show box
No errors are thrown, that I can see. Both accounts on the servers are using php 7.4. I saw many posts about a similar problem that said CORS needs to be enabled and it is on both servers. Any ideas on how to fix this or what to try?
Problem solved. I tried using Chrome instead of FF and its console reported a problem loading jquery due to the link not being secure. Changed that and it worked.
Related
We have two instances running of a joomla hosted site. One is on test server while the other one is on live server.
We are getting one issue where on the test server, site is displaying correctly but not on live server.
We zeroed on one particular line in the page source view, here is the difference of one function from both test as well as live server
test server
<script language="javascript">
$(document).ready(
function (){
$(".pikame403").PikaChoose();
});
</script>
live server
<script language="javascript">
$(document).ready(
function (){
$(".pikame<?=$list['id']?>").PikaChoose();
});
</script>
to me it looks like on the live server, php is not concatinating the id. Any hints/suggestions are welcome. Also it would be nice if someone could indicate where the addins are store their code.
Not all servers allow to use short tags <?= for echoing. On your test server short tags switched on, on production -- switched off, so they don't work.
You can solve your problem in 2 ways:
Switch on short tags on production server.
Do not use short tags (which I strongly recommend). Just change your code <?=$list['id']?> to <?php echo $list['id']; ?>.
Home URL is http
Login URL is https
I have found that if I change the login URL although it says you are submit unsecure data the functions work. However when in https the functions do nothing and I cannot debug it to see what's going on.
window.google.identitytoolkit.notifyFederatedSuccess({ "email": "email#domain.com", "registered": true });
does nothing. The page loads and the user as far as the site goes it logged in but the modal window is still open the the site needs to be refreshed to show that the user that they have logged in.
All window Google commands do nothing. Any idea why?
Page Code:
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/jquery-ui.min.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/googleapis/0.0.4/googleapis.min.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/jsapi"></script>
<script type="text/javascript">
google.load("identitytoolkit", "1.0", {packages: ["notify"]});
</script>
<script type="text/javascript">
window.google.identitytoolkit.notifyFederatedSuccess({ "email": "email#domain.com", "registered": true });
</script>
It was a huge mess using google identity toolkit to have one domain log you onto another. IE company site logging you onto product site, but it is well worth it. It involved building 2 sessioning engines.
I've set document.ready in the middle of a page.
It was working fine on local server, on an online production beta server, but failed on the final server.
Any suggestions?
thx
Code:
$(document).ready(function() {
And yes. JQuery is loading and it's working propely
UPDATE: These days I've found the same issue and for futher reference the script tag that includes the jQuery must be propely closed. If not the $(document).ready() is never called.
Wrong:
<script type='text/javascript' src='js/jquery-1.6.2.min.js'/>
Also wrong:
<script type='text/javascript' src='js/jquery-1.6.2.min.js'>
Right:
<script type='text/javascript' src='js/jquery-1.6.2.min.js'></script>
Nowadays using hmtl5 <!DOCTYPE html>
Get Firebug and check:
is jQuery loading or is it missing. And is it loaded before the document.ready ?
is the script throwing any JavaScript-errors?
The most likely problem is the production server doesn't have a copy of jquery. Switching to having google provide jquery for you is a good practice.
My web site want to be open IE7 and above .If IE 6 ,I want to produce warning and free download other browser icons .Is it possible?
You can get some examples that don't require server side scripting from ie6nomore.com.
They use the conditional comments feature of IE, like this:
<!--[if lt IE 7]>
Your browser is outdated!
<![endif]-->
But the examples on the site actually offer links to other browsers. Of course, you can roll your own version that suits your layout better.
Of course, you can do this server side if you prefer, since you're using PHP anyway. The other examples here using $_SERVER["HTTP_USER_AGENT"] should get you started. Using get_browser may be overkill, as it requires a fairly large data file to function.
If you're only interested in detecting old IE versions server side, this should do:
preg_match('/; MSIE (\d+.\d+)/', $_SERVER['HTTP_USER_AGENT'], $matches);
if (count($matches) > 1 && $matches[1] <= 6.0)
{
echo "Your browser is outdated";
}
Use IE conditional comments in your page
<!--[if lt IE 7]>
include a warning here (in an iframe, perhaps, to save extra bandwidth)
<![endif]-->
There exits a simple jQuery plugin for this it's called IE Alert. Check it out on: http://nmsdvid.com/iealert/
You can check the $_SERVER['HTTP_USER_AGENT'] variable for IE.
if (eregi("MSIE", $_SERVER["HTTP_USER_AGENT"]) ||
eregi("Internet Explorer", $_SERVER["HTTP_USER_AGENT"])) {
// IE
}
You should be able to do so easily by using the built-in get_browser function.
In case you wish to see what the output looks like if visited by IE 6, you can grab a user agent string from UserAgentString.com to test it out.
Alternatively you could also check it with a JavaScript
/*
* Check whether the current browser is IE6
*/
function isBrowserIE6() {
if (Sys.Browser.agent == Sys.Browser.InternetExplorer && Sys.Browser.version < 7) {
return true;
} else {
return false;
}
}
(The above would just work in a ASP.net environment. Here's a blog post which handles IE browser checking the native way).
You then add an HTML container element on your page
<div id="ie6BrowserWarning" style="display:none">
Your browser is outdated. Please download one of the alternative browsers!
<!-- Set of links to Firefox, Chrome, Safari, Opera,... -->
</div>
And on page load you do
<html>
<head>
<script type="text/javascript">
function doIE6WarningCheck()
{
var element = document.getElementById("ie6BrowserWarning");
var isIE6 = isBrowserIE6();
if(element != null && isIE6 == true)
{
element.style.display = "block";
}
}
</script>
</head>
<body onLoad="doIE6WarningCheck()">
<div id="ie6BrowserWarning" style="display:none">
Your browser is outdated. Please download one of the alternative browsers!
<!-- Set of links to Firefox, Chrome, Safari, Opera,... -->
</div>
</body>
</html>
I didn't check that, just wrote it out of my head right now. You'd have to do that, but I guess it should work. Firebug is always a good option for JavaScript debugging.
use their script to promote user to upgrade their browser its customizable.you can check any browser not only ie 6
http://www.browser-update.org/
How can I show a message to IE6/IE7 browsers to upgrade to IE8 and have IE8 not show the IE7 warning?
I have a page that does the following:
The browser loads a very simple page with a valid head and body, with only a script/noscript pair as content.
In the body, it has a script (script a) that runs a function onLoad. This function dynamically includes a second script (script b), and runs a function in it when it becomes available.
The second script is a .js file that does various work.
Both scripts are parsed by PHP and use the application/x-javascript content type.
Now, I have this all working just fine, except a couple of JS hiccups. JavaScript isn't one of my strong languages, so I'm hoping these are simple issues and somebody can point me in the right direction.
Problem 1: If I do a simple alert('you are in script b'); in the second script, it works as expected. However, if I do anything else, it works fine, and then the browser keeps indicating that it is loading forever. This is the color tween in firefox, or the spinning thing in IE.
I've tried ending the script in different ways, and nothing seems to help. Any idea how to indicate to the browser that the script is all the way loaded? It's a .js file that is forced to parse through PHP.
Problem 2: The second script doesn't seem to be included at all in either Opera or Google Chrome. Works fine in FF/IE, other than the loading issue. Can anyone see if Im using something that isn't compatible in the loading of the second script?
Thanks!
Update:
Thanks for the answers. I actually have firebug, which is why I know everything is working properly (in FF, at least). I don't actually know that the script isn't working in Opera/Chrome, but nothing happens.
It is quite a bit of code =o) I will copy the actual responses out of firebug and post those, so you can see exactly what the code is. As far as the webserver closing the connection, I was thinking that too, but it seems odd that if I make script b into alert('whatever'); it will alert and then stop loading, but it I do everything exactly identical, but make the script document.write('whatever); it will load forever.
Here are the scripts, updated, copied directly from the net tab of firebug:
Note that discoverfire.net is an internal domain, so you won't be able to load anything from there...
Initial HTML page:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Welcome!</title>
<style>body { font-family:arial; }</style>
<script language="JavaScript" type="text/javascript" src="http://www.discoverfire.net/analytics/l/a.js">
</script>
<script language="JavaScript" type="text/javascript">
document.onload = Start();
function Start(){
TAFKing_version = '1.0';
TAFKing_lkey = '19-8O-KKA8HV';
TAFKing_Lander();
}
</script>
</head>
<body>
<noscript>
Oops! We can't forward you properly because your JavaScript is turned off.<br /><br />
<a href='http://www.discoverfire.net/analytics/l/noscript/19-8O-KKA8HV.html'>Please click here to continue.</a>
<img src='http://www.discoverfire.net/analytics/l/imp/19-8O-KKA8HV.png' border='0' alt='tell a friend' />
</noscript>
</body>
</html>
** Script A (...a.js): http://www.discoverfire.net/analytics/l/a.js **
function TAFKing_Lander(){
version = TAFKing_version;
lkey = TAFKing_lkey;
var scrb = document.createElement('script');
scrb.type = 'text/javascript';
scrb.src = 'http://www.discoverfire.net/analytics/l/b.js?lkey='+lkey+'&version='+version+'&cb=4eohe8e65'
;
document.getElementsByTagName('head')[0].appendChild(scrb);
Interval = setInterval("Waiter()", 10);
return;
}
function Waiter(){
if(window.TAFKing_LanderB) {
clearInterval(Interval);
TAFKing_LanderB();
}
}
Script B (...b.js): http://www.discoverfire.net/analytics/l/b.js?lkey=19-8O-KKA8HV&version=1.0&cb=4eohe8e65
function TAFKing_LanderB(){
document.write("there are just a whole bunch of doc.writes here that build a simple table");
}
I bet it is nothing related with the scripts, but with the webserver. Your description, specially that it affects many browsers, and some of them don't even run the scripts, leads me to believe that the webserver is not closing the connection. Perhaps the webserver is not properly handling HTTP/1.1 Keep-alive requests.
Try using Firebug in Firefox. Install it, enable it for your page, reload the page and check the "Net" tab for what really is keeping the connection open.
This is a lot of code to go through. You should definitely get Firebug to help you diagnose it. The latest version will even show you when/if the onload events occur.
Firebug will also allow you to output message simply by writing console.log('somevar=',var); to test their values. You can even use the console to test value after the page has loaded since you're using the global name space.
Off the top of my head, I would make sure the connection properly closes in php. Also
document.onload = Start();
would assign the result of Start() to onload, not Start which is defined later.
Also window.onload is more compatible/standard.
You may want to save the output of your js files as outputphpA.js and outputphpB.js, directly source those and see if the loading behavior differs. That should help diagnose if it's a php issue.