Jquery.load URL from different folder - javascript

How do I use .load if my file is in different folder?
I have tried:
$("#messageWindow").load("http://localhost/MainFolder/Messanging/index.php");
$("#messageWindow").load("Messanging/index.php");
$("#messageWindow").load("../Messanging/index.php");
nothing works, I have read topic about different folders when using URL but I can't seem to make their answers work.
Thanks.
Okay, I have Fixed the problem The 1st and 2nd URL above WORKS but I have another problem. The index.php have tons of URLs.
<script type="text/javascript" src="../js/jquery-1.7.2.min.js"></script>
<script src="../plugins/ui/jquery.ui.core.js"></script>
<script src="../plugins/ui/jquery.ui.widget.js"></script>
<script src="../plugins/ui/jquery.ui.datepicker.js"></script>
<script src="../plugins/timezone/jstz.min.js"></script>
<script type="text/javascript" src="file_js/index.js"></script>
but now those URls are not working anymore, and the solution i took was to add the whole URL.
<script type="text/javascript" src="http://localhost/MainFolder/js/jquery-1.7.2.min.js"></script>
<script src="http://localhost/MainFolder/plugins/ui/jquery.ui.core.js"></script>
<script src="http://localhost/MainFolder/plugins/ui/jquery.ui.widget.js"></script>
<script src="http://localhost/MainFolder/plugins/ui/jquery.ui.datepicker.js"></script>
<script src="http://localhost/MainFolder/plugins/timezone/jstz.min.js"></script>
<script type="text/javascript" src="http://localhost/MainFolder/Messanging/file_js/index.js"></script>
this is a hustle if I uploade the file to my web host. I think using relative pathing would do the trick but I don't know how that works.

For jQuery load() you can include the relative path from the current page or an absolute path. If you run the command below in the JS console or firebug you should see this same question twice in your browser.
$("#header").load("/questions/10643503/jquery-load-url-from-different-folder");
Content also needs to come from the same origin as the original page (you can only load content from the same domain).

Related

index.HTML does not recognize script in folder (chrome)

I am creating a browser based game with phaser, which involves linking to an external javascript file with my own code in it. For some reason when I use either
<script type="text/javascript" src="/js/main.js"></script> or
<script type="text/javascript" src="js/main.js"></script>
to link the javascript to the HTML, no 404 is thrown but the script does not run. However, if I move main.js to the root directory and put
<script type="text/javascript" src="main.js"></script>
in the exact same spot, the script runs fine. Any theories as to why this is? I am using chrome version 57.0.2987.133. Thanks in advance!
It should be:
<script src="./js/main.js"></script>
You had a simple scoping error and forgot the script's src.

alert() not appearing on load in jQuery document ready handler

This is the code I use to show a message on my webpage.
<script type="text/javascript" src="jquery-1.9.1.js"></script>
<script type="text/javascript" src="jquery-migrate-1.0.0.js"></script>
<script>
$(document).ready(function(e) {
alert('success');
});
</script>
However, after the page loads it shows me nothing.
try loading the jquery files from a cdn, unless you're already hosting it-
e.g.
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
edit:
you say it's already apart of your server, I personally prefer making absolute paths to files..
e.g.
<script src="http://your.server.com/path/to/the/files/jquery.1.9.js"
obviously you'll need to get the actual path, and make sure it's got the correct permissions

sharepoint 2013 created site with ipad sometimes a few javascript file not loaded

We have a site created with sharepoint 2013. When I open site from ipad sometimes afew js file not loaded. This cause error in home page.
I included js file in masterpage like;
<script type="text/javascript" src="/SiteAssets/script/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="/SiteAssets/script/jquery-ui-1.10.4.custom.min.js" ></script>
<script type="text/javascript" src="/SiteAssets/script/XXX.js"></script>
<script type="text/javascript" src="/SiteAssets/script/AAA.js"></script>
<script type="text/javascript" src="/SiteAssets/script/YYY.js"></script>
<script type="text/javascript" src="/SiteAssets/script/ZZZZ.js"></script>
How can I solve this problem?
I got information about request number is limited with two for js files and js requests blocks all other request.
There were many assets(image,js,css) link in my master page.
So I tried to combine the js files and decrease the number of request for js files in two.
This solved my problem.
Descrease the number of requests as you can.

External Javascript not working even though I linked it right(at least I am quite sure about that)

I am very new to web design and trying to build a responsive page using Bootstrap. Everything works except my linked JS. I am sure the path is right but neverthelast I tried to put my JS on server and indicated the full path through http:// but still not working. I even put all my scripts in the head section just in case but still not working. Start getting frustrated anyone please can help me guys :) The JS is in the 'scripts' folder which is in the same folder with my 'index.html'.
This is my html in the head section:
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js"></script>
<script type="text/javascript" src="scripts/script.js"></script>
And here is my external JS:
$(document).ready(function(){
$("#menu").slideUp("slow");
});
Your problem is loading in the jQuery. It's trying to load your first script from a relative path. Try replacing the first script with <script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>

Image cannot be loaded. Make sure the path is correct and image exist

SO my file hierarchy that is the same on my desktop as it is in my web-host file manager
1- This is my iframe from my code editing program (Adobe Edge Code) correctly working when I throw the page up in Google Chrome]
2- And this is my iframe not working when I have the page hosted in my web-hosts file manager.
1: https://pantherfile.uwm.edu/leyton/Screen%20Shot%202013-12-20%20at%203.51.37%20PM.png?uniq=-n0ztwi
2: http://leytonelizabeth.com/photography.html
I don't know anything about Javascript and definitely nothing about JQuery. All I know is that I have a code that correctly displays my website when I preview it on Google Chrome.
When I put all my files in the exact same hierarchical order in my web-hosting site's file manager, I navigate to it and it doesn't work.
Why does it point to the files and paths correctly when it's coming from my desktop and not when it's coming from Webhostinghub.com?? I transferred them over in exactly the same order. The paths are correct. So it must be something with jQuery. Can anyone give me some advice or things to try in order to get the iframe to display my photos?
Is it perhaps because there are several Core Scripts being referenced at the top of my photography.html page? do I need to update/download each version? Do viewers looking at my site need to go through all that too then just to potentially see the photos in my iframe? As you can see in the pic of the photo that properly works in the iframe, it points to the prettyPhoto jQuery and its respected gallery, not some other url..
I have NO IDEA what to do about this. Please help!!!
These are the scripts at the top of all my html5 documents/pages:
`<!-- Cufon Scripts -->
<script src="js/libs/cufon-yui.js" type="text/javascript"></script>
<script src="js/fonts/mank-sans.cufonfonts.js" type="text/javascript"></script>
<script src="js/fonts/Yanone_Kaffeesatz_Regular_400.font.js" type="text/javascript">
</script>
<script src="js/royale-cufon.js?v=1" type="text/javascript"></script>
<!-- Core Scripts -->
<script src="js/libs/modernizr-1.7.min.js" type="text/javascript"></script>
<script src="js/libs/mdetect.min.js" type="text/javascript"></script>
<script src="js/libs/jquery-1.6.2.min.js" type="text/javascript"></script>
<script type="text/javascript">jQuery.noConflict();</script>
<script src="js/libs/jquery.easing.1.3.min.js" type="text/javascript">
</script>
<script src="js/royale.js?v=1" type="text/javascript"></script>
<!-- Bg Image Script -->
<script src="js/royale-bg-image.js?v=1" type="text/javascript"></script>
<!-- Added for Lightbox Script -->
<script src="js/libs/jquery.pretty-photo.min.js?v=1" type="text/javascript"></script>
<!-- Setup Script -->
<script type="text/javascript">`
1 Lots of your 'thumb' folders are empty.
2 The "big-sized" picture of teacup (the only thumb picture i can see) is referred as "img/portfolio/theaccident/tea.jpg", but the real file path is "img/portfolio/theaccident/Tea.jpg" (the capital letter matters)
So the problem is not in the scripts, It's in your export settings or your host defaults.
UPD:
3 Some links from your 'thumbless' pictures are pointing to correct 'big-sized' pictures (their first letters are not capitalized).
You definetely did something wrong when moving everything from desktop to host.

Categories

Resources