Jump to content

for experts: how to make "loading....." ?


ahmedm177

Recommended Posts

Depends on the requirements. You'll have to be more specific. At a high level glance I would guess this is more of an Ajax thing and would require PHP and Javascript to work in conjunction.

 

i was think that there are way with only php

 

do u know how i make it with javascript, give me any small example.

If you absolutely didn't want to use ajax (although I would recommend using it), inside of the php function you'd have to echo a javascript script that will show the loading symbol, and then at the end of the function echo a javascript function that hides it.  Basically it'd be a very simple show/hide that happens at the beginning and end of the function.

 

Simple Example:

function sampleFunction(){
  echo "<script type='text/javascript'>document.getElementById('loading').style.display = 'block';</script>";
  // Run php code here
  echo "<script type='text/javascript'>document.getElementById('loading').style.display = 'none';</script>";
}

let suppose the div's id is "loadingdiv" then you can do like this in javascript for that

$('loadingdiv').innerHTML='Loading.....Please wait';

 

Thats all dude...

That doesn't work. Wrong jQuery usage too.

 

But roshanbh does bring up the most used way of doing this. With the div id being 'loadingdiv':

document.write("<div id='loadingdiv'>Loading...Please wait</div>");

 

Then under that, you can have something like:

var something = "FILL IT IN! YOU CAN USE PHP TO GENERATE THIS TEXT";
document.getElementById("loadingdiv").innerHTML = something;

let suppose the div's id is "loadingdiv" then you can do like this in javascript for that

$('loadingdiv').innerHTML='Loading.....Please wait';

 

Thats all dude...

That doesn't work. Wrong jQuery usage too.

 

But roshanbh does bring up the most used way of doing this. With the div id being 'loadingdiv':

document.write("<div id='loadingdiv'>Loading...Please wait</div>");

 

Then under that, you can have something like:

var something = "FILL IT IN! YOU CAN USE PHP TO GENERATE THIS TEXT";
document.getElementById("loadingdiv").innerHTML = something;

 

please how can this work ? more explain please

Uh...because it does? I don't know. That's how JavaScript calls the ID and puts text into the node. : S

 

Maybe if you tell me in more explicit details on what you don't understand about that, I can explain it to you.

 

BTW, this needs to be moved. This topic doesn't belong here.

Uh...because it does? I don't know. That's how JavaScript calls the ID and puts text into the node. : S

 

Maybe if you tell me in more explicit details on what you don't understand about that, I can explain it to you.

 

BTW, this needs to be moved. This topic doesn't belong here.

 

first i dont know javascript

i want when i click on button in my page, something like please wait.. appear thats all

so where i can put ur code to do that ?

i just have php code file

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.