Re: [PHP] Is it possible to click download button,and run 2 tasks downloading a file and show number of downloads(ajax)simultaneously?

2012-10-15 Thread Negin Nickparsa
Thanks Tedd,

ajax works fine now,when submiting a button it will show the number and it
doesn't have any problem


$(function() {

 $(.button).click(function(){
 var id=$(this).attr('id');
 var dataString = 'id='+ id ;
$.ajax({
   type: POST,
   url: download_number.php,
   data: dataString,
   cache: false,
   success: function(html)
   {
  $(#div_+id).html(html);
  }  });
}

button:

input type = button value=Download class=button id=?php echo $id;
? 

div:

div id=div_?php echo $id; ? ?php echo $downloadcount;?/div



by the way* I totally will refuse this approach* because,although the ajax
is working,but I can't do anything for click to download the related file
because when I go to my php page I can't redirect it to a page for download
and besides echo the output to be written in div element,so that,the best
solution is just redirect to a page and download the file in first place.
after submiting write a $_POST['submit'] and just store the download
count,update the table and if user refreshed the page,can see the number of
downloads,*as sure there isn't anything better than this.*

Marco suggested me iframe,reloading it,like a manual ajax but I think it
has much of troubles.

by the way thanks for all helps.


Re: [PHP] Is it possible to click download button,and run 2 tasks downloading a file and show number of downloads(ajax)simultaneously?

2012-10-15 Thread Negin Nickparsa
oh my bad:)! there is a cool solution,I forgot the blank page!:) yep!
solved:)


 window.open('download.php', '_blank' );

now I can count up,and download:)

 $(.button).click(function(){
 var id=$(this).attr('id');
 var dataString = 'id='+ id ;
$.ajax({
   type: POST,
   url: download_number.php,
   data: dataString,
   cache: false,
   success: function(html)
   {
  $(#div_+id).html(html);
  }  });
 window.open('download.php', '_blank' );
 });

so cool!!:)

On Mon, Oct 15, 2012 at 7:42 PM, Negin Nickparsa nickpa...@gmail.comwrote:

 Thanks Tedd,

 ajax works fine now,when submiting a button it will show the number and it
 doesn't have any problem


 $(function() {

  $(.button).click(function(){
  var id=$(this).attr('id');
  var dataString = 'id='+ id ;
 $.ajax({
type: POST,
url: download_number.php,
data: dataString,
cache: false,
success: function(html)
{
   $(#div_+id).html(html);
   }  });
 }

 button:

 input type = button value=Download class=button id=?php echo $id;
 ? 

 div:

 div id=div_?php echo $id; ? ?php echo $downloadcount;?/div



 by the way* I totally will refuse this approach* because,although the
 ajax is working,but I can't do anything for click to download the related
 file because when I go to my php page I can't redirect it to a page for
 download and besides echo the output to be written in div element,so
 that,the best solution is just redirect to a page and download the file in
 first place. after submiting write a $_POST['submit'] and just store the
 download count,update the table and if user refreshed the page,can see the
 number of downloads,*as sure there isn't anything better than this.*

 Marco suggested me iframe,reloading it,like a manual ajax but I think it
 has much of troubles.

 by the way thanks for all helps.






Re: [PHP] Is it possible to click download button,and run 2 tasks downloading a file and show number of downloads(ajax)simultaneously?

2012-10-14 Thread Tedd Sperling
On Oct 14, 2012, at 7:41 AM, Negin Nickparsa nickpa...@gmail.com wrote:
 I wanted to refresh the download count when clicking the button first is it
 possible?

Yes, it is possible.

The following is an example of a server-side php script refreshing a Web page 
via a javascript client-side action:

http://php1.net/a/zipcode-states/

The action is triggered by simply using the selection control, which in turn 
activates an onchange javascript routine that causes a slave php script to run 
retrieving data from a database returning the data thereby causing an ajax 
script to update the selection control.

All the code (html, javascript) is there except for the php script, which 
should be trivial to write.

Cheers,

tedd
_
t...@sperling.com
http://sperling.com





--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php