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

  • Home
  • SEARCH
  • 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 8256145
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T01:45:47+00:00 2026-06-08T01:45:47+00:00

I have developed a site on my local machine and got it working fine,

  • 0

I have developed a site on my local machine and got it working fine, but after uploading it to my remote host, the ajax/json calls fail to run.

I have checked for any html being written before the redirects are run and the only things I can find are where I am echoing json_encode($return).

Is this the problem? And if so does anyone know how I can fix this.? An alternative to using echo maybe??

thanks

Code below with labels as to where I think the problem might be…

<script type="text/javascript">

$(document).ready( function() {
    $("#addStory input[type=submit]").click(function(e) {
        e.preventDefault();
        $.post('editor.php', $("#addStory").serialize(), function(result) {
            alert(result.adminList);
        }, "json");
    });
});

</script>



<form name="addStory" action="" method="post" id="addStory">
    <input type="text" id="test_text" name="test_text" />
    <input type="submit" value="Submit" />
</form>

And here’s editor.php…

<?php

header('application/json');

$return = array();
$return['adminList'] = "Hello World!";
echo json_encode($return);

?>

The “Hello World” alert does not happen…

  • 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-08T01:45:50+00:00Added an answer on June 8, 2026 at 1:45 am

    One problem you do have is the second header('application/json') is placed after the output of the first SQL query. This is only the case if $row['column_name'] == 0 is true though.

    If it is always going to return json then just set this right at the top of the php code to avoid confusion later on.

    <?php
        header('application/json');
    
        //all your sql etc here
    
    ?>
    

    I also noticed during our discussion that your header is actually incorrect. It should be

    header('Content-type: application/json');
    

    Removing it would also work however this is probably a bad idea since this serves the purpose of telling the recipient what type of data to expect.

    Another point is that your current ajax should really be taking advantage of the getJSON() function in jQuery which will automatically give you back a json object.

    $.getJSON('example.php', function(data) {
        //use data as a json object
    }); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Working on several remote sites, and have a copy of each site on my
I have developed a site with ASP.NET MVC 1, and now I'm trying to
I have developed a site, which has some static pages. Like explore, home, feedback.
I have developed a web site that requires user registration and authentication for some
i have developed our company site where we show one product detail means one
Hey guys, I have developed a small site that i would like to embed
I have a web site already developed with tons of updatePanels, buttons, and integrated
I have a asp.net web site that was developed on the .Net Framework v2
I develop a web application it is working fine in local. When i upload
I developed one site with session. Its works in Local server and Also in

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.