Load div when i open the page - html

Good Morning comunity, im really new on this coding so iam sorry if this question is too noob.
I want a DIV PA load automatically a php file when i open the web page, please i dont want to load with any interval, just load instant when open web.
I tried this code but im sure it is not working
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/
libs/jquery/1.3.0/jquery.min.js">
</script>
<script type="text/javascript">
$(document).ready(function)()
{
$('#apDiv3').load('xFile.php');
}
);
</script>
Thank you in advance for your time!!

Have you checked the result with a debugger like Firefox's Firebug? Check the network communication to see if the ajax request was completed successfully.
Also, you can try to a callback function to see if the code was executed successfully:
$( "#result" ).load( "ajax/test.html", function() {
alert( "Load was performed." );
});
if you don't get the expected output, it might be a problem on the server-side.
Also... are you sure you are using this exact code? I don't think you should close the brackets after function
$(document).ready(function)
this is how you do it:
$(document).ready(function() {
....

Related

Load content from URL into content-column

I am facing an issue with my script that uses the jQuery .load() method. The script is designed to load the content from a URL into a specific element on my page when a user clicks on a nav link. However, I am receiving the error message "TypeError: $(...).load is not a function." and I am not sure why this is happening.
Here is my script:
<script>
$(document).ready(function() {
// Add click event listener to all nav links
$(document).on('click', '.nav-link', function(event) {
event.preventDefault();
// Get the URL of the clicked link
var url = $(this).attr('href');
// Load the content from the URL into the content-column
$('#content-column').load(url);
});
});
</script>
I have made sure that I am using the latest version of jQuery and that it is properly included in my HTML file.
If anyone has any experience with this issue or knows how to resolve it, I would greatly appreciate your help.
Thank you!
Currently all scripts I have tried either result in a redirect to the actual url or the script works for one click and then stops working after that.

Bokeh Inline Embedding, 'Failed to load resource'

I'm having an issue with embedding Bokeh inline. Particularly, there is an issue with loading the resources from the 'link' tag (refer to html snippet below). For some reason, when I try try to embed a Bokeh plot inline, the following error occurs: 'Failed to load resource: the server responded with a status of 404 (Not Found)', referencing this link - https://cdn.bokeh.org/bokeh/release/bokeh.min.css.map
However, the above address is different from the one I indicate in the link tag (it omits the bokeh version at the end). I have no idea why this error occurs, it's the first time that this happens. I have previously used inline embedding successfully on a number of occasions.
<head>
<link href="https://cdn.bokeh.org/bokeh/release/bokeh-0.12.1.min.css" rel="stylesheet" type="text/css">
<script src="https://cdn.bokeh.org/bokeh/release/bokeh-0.12.1.min.js>
</script>
</head>
EDIT
I am trying to use inline embedding together with jQuery (I would like to display different Bokeh plots without reloading the entire page every time).
When I looked for further error details in the console, I found the following error: "Error rendering Bokeh model: could not find tag with id..."
If it's of any relevance, here is the jQuery script in my html:
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type=text/javascript>
$(function() {
$('a#process_input').bind('click', function() {
$.getJSON('/background_process', {
proglang: $('input[name="proglang"]').val(),
}, function(data) {
$("#result").html(data.a);
$("#r").html(data.b);
});
return false;
});
});
</script>
Where 'data.a' and 'data.b' are the Bokeh-generated script and div tags, respectively.
Any suggestions or advice would be much appreciated!
Best guess is that the script is executing first/early, before the <div> is inserted into the DOM. You will need to find a way to guarantee that the <div> is available by the time the the script executes.
As an aside the partial load use case was not really envisioned when the componenent function was created. If you want to do partial loads, it might be better to serve the doc JSON and then calling Bokeh.embed.embed_items directly on from JavaScript somehow. But it would probably take some experimentation and discussion and back and forth to get that working, which SO is not very good for. I'd encourage you you bring this topic to the public Discourse for further discussion.

console.log() not showing in console but in page in Smarty

Ok im having this issue with some smarty files and variables and i need to use console.log.
Issue is console.log is empty and the code appears on the webpage.
for example
console.log('$affiliate.id'); console.log('$affiliate.firstname'); console.log('App started'); console.log("App started");
Shows up in tha page.
PS: Is there some kind of an issue cause its tpl files?
PS2: I tried all the versions like ', " in case i was wrong :P
Thanks in advance
You have to put your code inside <script> tags.
For example:
<script>
console.log('{$affiliate.id}'); console.log('{$affiliate.firstname}'); console.log('App started'); console.log("App started");
</script>

Load div last after page load

Ok So I have a div that loads some data and makes the entire page load slowly. Fortunately this data can wait and I would like to load it last. I've seen the other posts like this but need a bit more help getting it to work as I am fairly inexperienced.
So for example I have:
<div id="stuff">
<?php Some PHP Here ?>
</div>
Now I have
$(window).load(function () {
$('#stuff').load('');
});
A few questions...Do I create an empty div and then fill it with the data or can I have the data in there and then specify that to load last, which would be preferred if possible.
I understand I can have a webpage loaded like $('#stuff').load('stuff.php'); but I use a variable inside the div so how would I pass it to that load function and into the php page?
I just don't know how to pass variables up to the javascript everytime that div is loaded as it's in a while loop.
Thanks for the help.
Because javascript processes on client side and PHP runs on server side, you cannot do PHP operations on HTML that have already been loaded (page has already been sent from server to client, so it is not reachable by PHP anymore).
Bacause of this fact you are going to need javascript AJAX for this.
Because you are beginner I suggest you use an ajax function from jQuery javascript framework for this matter. It works the same as javascript function and handles many operations automatically.
As you correctly presumed, you can first display your empty div and then, ... after page is fully loaded, you can call your ajax.
This ajax basically asks PHP script to provide loaded page with data that will be displayed in specified html element.
Code should look like this:
Include this to your PHP file with content that you load:
<script type="text/javascript">http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.js</script> <!--loads jquery framework-->
<script type="text/javascript">
$(document).ready(function() {
//when page is loaded
$.ajax({
url: "ajax.php" //script with your data selection
}).done(function(data) { //when ajax call success
$("#ajax-element").html(data); //insert data returned from ajax.php into div with id ajax-element
});
});
</script>
<div id="ajax-element"></div>
This is PHP ajax file that will return data for you (just echo everything that you want to have in your "ajax-element" div, for example:
<?php
echo "some text";
?>
For more info you can find jquery AJAX specification here.

Request.HTML mootools 1.2.5 load external file javascript

I have ajax tabs that load external files
see demo here please bottom of the page
http://www.php-help.ro/examples/mootools_fancy_tabs/
they work perfect but my external file has additional 1 javascript file and inline javascript
example :
<script type="text/javascript">
window.addEvent('load', function(){
/*something here*/
});
</script>
on tab load any request to script tag is removed , I dont see anywhere in the file itself that
evalScripts: is set to false , I also added it in right after
url:this.tabs[key].get('href'),
I setup the file on Jsfidle but seems like ajax can load only internal files
http://jsfiddle.net/PUsBg/16/
if anyone could help me out just to be able to load my own script within the ajax tab.
Thank you!
This is probably the result of parsing the request, with the javascript being thrown out in the process. If you include javascript within a CDATA-section, it should not be parsed and still be included:
<script type="text/javascript">
/* <![CDATA[ */
window.addEvent('load', function(){
/*something here*/
});
/* ]]> */
</script>