Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6996933
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:13:11+00:00 2026-05-27T20:13:11+00:00

I hava a PHP script which generates a PDF file (i’m using fpdf from

  • 0

I hava a PHP script which generates a PDF file (i’m using fpdf from http://www.fpdf.org). I’m calling the PHP from an html using AJAX $.post(…..). When submit button is clicked, the span shows ‘please wait…’. The PDF is getting generated but still the span shows ‘please wait…’. The span is not getting updated. Below is the code for AJAX call:

$(document).ready(function()
{
$("#genByDt").submit(function()
{
    $("#msg").text('Please wait....').fadeIn(1000);

    var otherValidations = validate(document.genByDt);
    if(otherValidations == false)
    {
        return false;
    }
    else
    {

        $.post("/pawn/fpdf/chittiCode/generateChitti.php",{ whichSubmitted:$('input[name = whichSubmitted]').val(), dateSelected:$('input[name = dateSelected]').val() }, function(data){

        var obj = $(data);              

        if($.trim($(obj,'body').text()) == 'success')
        {
            $("#msg").fadeTo(200,0.1,function(){
                $(this).text('Bills generated successfully !!').fadeTo(900,1);
                $('input[name = dateSelected]').val('');
            });

        }
        else if($.trim($(obj,'body').text()) == 'zeroBills')
        {
            $("#msg").fadeTo(200,0.1,function(){ 
                $(this).text('No bills for the selected date !!').fadeTo(900,1);
                $('input[name = dateSelected]').val('');
            });
        }

        });

        return false; //not to post the  form physically
    }
});

});

I know the problem is in the IFcondition. The PHP is returning a string but the $(data) is of type object[ I found this by using alert(obj); ]. Below is a part of the PHP:

if($success == 1)
{
echo "success";
}
else
{
echo "zeroBills";
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T20:13:12+00:00Added an answer on May 27, 2026 at 8:13 pm

    If the PHP is returning a string, then data will be a string and should be treated as such:

    if (data === "success") {
       // your code here
    } else if (data === "zeroBills") {
       // your code here
    }
    

    (You mentioned you found the type of obj by saying alert(obj); what happens if you say alert(data)?)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I hava a data window object, in which I am fetching some attributes from
I hava a webview showing some contents which is getting from server. Now on
I hava a CSV file that I want to treat as source code. Essentially
I hava a function that looks something like this: require(config.php); function displayGta() { (...
I hava the sql as below: select a.dept, a.name from students a group by
I hava a script that consist of hello world and the hello and world
I hava java swing project which is developed in JBuilder IDE. Now I need
for example, I hava a partial template named _header.php, I want to use it
I hava a MySQL Statement which joins 2 tables and shows the result in
I hava read from Khalid Mugal and others that the conditional operator is right

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.