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 8969861
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T17:39:10+00:00 2026-06-15T17:39:10+00:00

I run $.post() the first time witch returns the correct data json data to

  • 0

I run $.post() the first time witch returns the correct data json data to run the if statement but the next time $.post() is used it returns incorrectly causing the if statement to not work as intended.

My current Jquery code:

$.post('functions/write_settings.php', { dbname: $('#dbname').val(), dbhost: $('#dbhost').val(), dbpassword: $('#dbpassword').val(), dbusername: $('#dbusername').val(), dbprefix: $('#dbprefix').val() }, function(data){
    alert("here");
    try{var returndata = $.parseJSON(data);}catch(e){/*cont*/}
    alert("here1");
      if($(returndata).size() >= 1){
          for(var i = 0; i < $(returndata).size(); i++){
              $("#" + returndata[i]).css('background', 'url(style/install/database/imgs/textbox_error.png)');
          }
          ResetButton();
          alert("here2");
    }else{
        $.post('functions/check_settings.php', function(data){
            alert(data);
            var postdata = data;
            $.trim(postdata);
            if(postdata == 'error'){
                alert("test2");
                $('#pdbe').show();
                $('#pdbe').effect("pulsate", { times:10 }, 10000);
                ResetButton();
            }else if(data == '0'){
                alert('connected!');
            }
        });
    }
});

This is check_settings.php

$cwd = getcwd();
$file = $cwd.'/dbconfig.php';
//check dbconfig created
if(file_exists($file)){
    include('./dbconfig.php');
}else{
    echo("error2");
    die();
}

//grab required vars
$host = $config['db']['host'];
$dbname = $config['db']['dbname'];

//test basic connection
try{
   $dbh = new PDO("mysql:host=$host;dbname=$dbname", $config['db']['username'], $config['db']['password']);
   $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}catch(PDOException $e){
   echo("error");
   die();
}
echo("0");

Like i said the first $.post() returns the correct data while the second time when it uses it it will return incorrectly and cause the if statement to not work correctly.

any suggestions to fix this issue would be greatly appreciated!

  • 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-06-15T17:39:11+00:00Added an answer on June 15, 2026 at 5:39 pm

    Is your problem the extra spaces? If so, in the check_settings.php you may be unknowingly printing spaces or new line. For example, you may be having space or new line before the first

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

Sidebar

Related Questions

this is my first time to post a question here, I will try to
In Visual Studio 2008 we run a post build event which calls NANT and
I am trying to run a system call which will post an activity to
According to this post , IDEA uses Osmorc to run OSGi frameworks. It, in
I followed this post http://neurochannels.blogspot.com/2010/05/how-to-run-r-code-in-matlab.html , to install R(D)Com server in order to call
We run an ASP.NET MVC application, and want it to post geolocalized tweets to
I want to run function inside web service (.asmx file) $.ajax({ type: POST, contentType:
I could try to post and explain the exact query I'm trying to run,
I read somewhere that you would never run syncdb on a database, post its
I am doing a simple $.ajax request: $.ajax({ type: POST, url: /Run/ + param1

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.