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.

Link to comment
Share on other sites

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>";
}

Link to comment
Share on other sites

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;

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.