Highcharts showing in some pages, not showing in root pages - php

I included Highcharts using php.mysql,ajax in my website. it is running fine in pages with url structure "abc.com/xyz/" but not running un "abc.com/qwerty.php". All other jquery calls are done in header file which is constant throughout. What can be the problem? Any help will be highly appreciated.

Judging by your response to my comment, you are definitely having problems with relative URLs. Change your <script /> URLs to be absolute. For example:
<script type="text/javascript" src="/js/dxJ_uCBsir4yQMacwqm_6l.js"></script>
Notice the preceding / in the src there. If the scripts are not available from /js/... on your Web site, then adjust accordingly, e.g.:
<script ... src="/some/path/js/dxJ_uCBsir4yQMacwqm_6l.js"></script>
If you do this, you will not have problems referencing the scripts from paths of varying / depths, which is clearly the problem you're having based on the symptoms you described. :) Hope this helps.

You can try to change permission of that file.
Right Click that file and Change Permission as Read/view/Write.
I had same problem in CPanel. I done this one. Then it's working fine.
Just Try it.

Related

CodeIgniter paths messing up CSS background-image directive

So, I am working on a website with backend for two customers. Both will have different URLs. I had a problem with Javascript links (ajax calls using url:) but that was solved using a global :
var SiteURL='<?php echo base_url();?>';
and append it to calls as necessary. The problem is when my paths go deeper e.g. website.com/book/sheet/2
the relative links would continue from 2/
While I am done with the JS, I am really lost on the CSS. I don't want to give absolute path, e.g. for background-image:url() as it will change with new customers.
Any way I can make use of base_url() or any other function?
#DFriend: that somehow failed for mine as it looked for images folder in css...Firebug showed "http://localhost/samplestud/assets/css/images/listicons/arrow_double.png"
Simple "../images" seems to have fixed it pretty well. Thanks fellas.

Including file in Joomla - what is the difference?

Can anyone tell me what is the difference between including the js script file in the following two ways,
I made this inside system plugin in joomla and included the js file inside "onAfterInitialise" function.
1)
<script type="text/javascript" src="<?php echo JURI::base(); ?>/plugins/system/test/script/script.js"></script>
This works fine and including the js file correctly, But when I logged-in from the backend the font size from userlisting and listing from other extensions gets enlarged.This is not the issue in my js script.
2)
$document->addScript(JURI::root(). "plugins/system/test/script/script.js");
This works fine without any issues.
Can anyone explain what goes behind this.
Using the second method is simply using Joomla coding standards and adds your script in between the <head> tags.
There isn't much difference except for where the script gets imported on the page.
JURI::base() and JURI::root() are both the same. They both define the root folder for your Joomla site. If you are unsure which one to use, I would recommend using method 2, as it's always good to get used to Joomla coding standards.
You can see the source of addScript() :) Basicly, if you use first method, your srcipt will be added in the same place you wrote the code. Second method will add link to a inner table in $document and will be 'rendered' at the
<head></head>
section at the end of page processing.

jQuery trying to load a non existent ajax-loader.gif mod-rewrite doesn't work

If you visit this page in Chrome:
http://www.immigrationconsult.org/contact.php
And Inspect Element on the page, go to Console you will see this error:
GET htt...cms/contact/images/ajax-loader.gif 404 (Not Found) jquery.min.js:4
I followed the instructions here to create a:
http://css-tricks.com/weird-file-requests-and-easing-server-stress-with-htaccess/
I tested to make sure it works, and it does, but not on this specific request. jquery.min.js is the jQuery minified from the makers, I did not change it at all. I used Agent Ransack to deep search for any reference of this in any of my files, the search yielded no results.
I have no idea what to do or how to prevent this issue from happening, this seems like such a small issue, but I can not locate the cause of the problem! Please help.
So, it was really a misdirection by Chrome. The plugin at fault was jQuery Coda-Slider. Because it was JS compressed, Agent Ransack couldn't find the string... lesson learned...
You clearly don't have the ajax-loader.gif file in the correct directory, or at least your ajax script is looking the wrong place.
you can either modify the java script to point to the right location or you can just put the file in the correct location, i would choose the latter.
I have had these errors my self with JQuery, where some icons didn't get loaded, just had to put them in the correct folder and it worked.
But if you use googles jquery libs, all resources should get loaded automagic as well. Like this...
<script type="text/javascript"
src="http://www.google.com/jsapi">
</script>
<script type="text/javascript">
google.load("jquery", "1.7.2");
google.load(etc..);
</script>
You need to download the entire zip file from their website: http://jquerymobile.com/download/. After you unzip it, you will find the js file, the CSS and a folder called "images", all of which need to be present locally.

script src attribution sometimes doen't work in .php file

i wrote like this as follow in a php file (for example: a.php)
<script src="scripts/a.js"></script>
<div>
.....
</div>
I can guarantee that the path of js file is right, because i can see the js content in firebug HTML-view. However, in Script-view there isn't a.js. It seems that a.js has been added into the html but can't be loaded, but some other js files can be recognized. And if I paste the js content directly in the DOM, it works.
I'd like to know when doesn't work and why? thanks a lot~
Answer: There's some serious syntax errors in my js file. The error may be too serious for the browser to recognize it...
I can't give you a positive answer as there's very little details, but you should use an absolute path to your JavaScript.
<script src="/scripts/a.js"></script>

How to know php file is loaded from source code

I'm working with my JS files, what i have now is a unique php file with JS header, if a variable is set it includes the real js file, which is fine.
The "home" page has the script tag for the php-js file:
<head>
<script type="text/javascript" language="javascript" src="bootstrap.php"></script>
</head>
the bottstrap.php file has something like:
if(isset($hostData) && !empty($hostData)) {
include('bootstrap.js');
}else {
echo "document.write('<center><bold>PLEASE DO SOMETHING...!</bold></center>');";
}
all that seems to be fine, however when viewing the source code (CTRL+U) the browser shows the "bootstrap.php" part as a link, if clicked it obviously redirects to http://mydomain/bootstrap.php and the js code can be easily seen, which is exactly what i don't want...
So my question is, is there any php-way to know if the file is being loaded from browser's "rendering view" or being loaded from browser's "source code view" ???
Any help is truly appreciated =)
In short, no. You can't hide your script source from your users. The best you can do is obfuscate it using tools like YUICompressor.
There's no way you can hide the javascript code. It needs to be executed by the client, and even if you try to hide it by formatting your code badly, tools like firebug can easily introspect the code and pull out the code.
To be honest I don't think you can actually hide it like that. I'm assuming the best thing you've got to go on is the useragent string but I'm assuming if you "view source" in a browser it would still send the regular headers.
The only way I can think of adding the JS include without it appearing when in view source mode is to actually load the external file via javascript (you could even break the path of the js file into variables so it isn't really human readable) which I would not advise.
If someone wants to get at your javascript they will there no is way of avoiding it.
and the js code can be easily seen, which is exactly what i don't want...
You don't want the JS to be seen, but you do want to use it???
There IS something wrong with your code though if you want the js file to be used in your page.
You need to include / require the file:
<script type="text/javascript" language="javascript" src="<?php include bootstrap.php ?>"></script>
Otherwise the browser will load the contents of the bootstrap file, but you want to run the code inside it (which can only be done at the server).
Also:
change:
include('bootstrap.js');
to
echo bootstrap.js;
EDIT
by re-reading your question (and other answers) that's exactly what you want: make your JS code invisible (correct me if wrong).
The answer to that is: No cannot be done.
You can try to obfuscate the code but it will take someone who wants to see it seconds to 'decode'.
Try using the $_SERVER["HTTP_referer"], which have the url that called this file.
I'm really sorry for disappearing from here...
The best solution I decided to implement is quite simple: don't show ANY URL or PHP files within JS code; so during last months I've used a unique PHP file to do all necessary database queries, a stored procedure generates dynamically all the URL's needed from JS.
In that way URL's vary every time and what I've named "poor logic" goes free for users to view/copy I don't mind that while server data is secure.
THANKS ALL FOR YOUR VALUABLE ANSWERS!!!

Categories