View Single Post
  #1  
Old 06-28-2011, 10:24 AM
alvidales is offline alvidales
Registered User

Join Date: Jun 2011
Posts: 1

Plain Trying to get php script to work with ajax(jquery)

Hi there, i'm new in this forum i'm wondering if is there anyone who could help me with this.

I'm trying in one php file to call from a button

Code:
<input type="button" onclick="javascript:exportexcel(<?=$month?>, <?=$year?>"/>
and the code for the js function is:

Code:
    function exportexcel(month, year){
       $.ajax(
        {
            url: 'exportexcel.php',
            cache: false,
            contentType: "application/x-www-form-urlencoded",
            dataType: "html",
            success: function()
            {
                    //alert('something');
                    $('#msg').html('Sales report build succesfully');
                    $('#msg').css('display', 'inline-block');
            },
            type: "POST",
            data:"month="+month+"&year="+year+""
        });
    }
if i uncomment the alert, it shows the alert window, but i can't make it to work, the file exportexcel.php generates data and exports it to excel, afterwards it sends prompt to user to save it or it just starts to download, is there any other way to make it work??, thx in advance.
Reply With Quote