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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T14:01:08+00:00 2026-06-13T14:01:08+00:00

hi i search alot for get a respone from php back and if that

  • 0

hi i search alot for get a respone from php back and if that respone is ok do someting and if its false do something else(!!!!!!!! WHENE I HAVE OTHER OUTPUT FROM THAT PHP !!!!!!)
this is my index file

<head>
<script src="jquery-1.7.2.js" type="text/javascript"></script>
<script src="js.js" type="text/javascript"></script>
</head>
<body>
<p> click </p>
<input type="text" id="who">
<br>
<input type="text" id="why">
<div id="bg" align="center">
</div>
</body>

this is my JS file

$(document).ready(function(){
    $('p').click(function(){
        var who = $('input#who').val();
        var why = $('input#why').val();     
        $.post('file.php',{who:who,why:why},function(data) {
    if(data.success){
         alert(data.message);
    }
    else{ alert('ERROR:' + data.message);
    }
});




    });
});

and this is my file.php

<?php
$response = array('success' => 'true', 
    'code' => "jQuery('#bg').html('\"Javascript\", \"json\", \"PHP\"');");
echo json_encode($response);
?>

my question :
1- why this is not work i get alert (error:undifined)
2- how i can get some result from that php file when its have other output
like this:

<?php
echo "1";
echo "2";
echo "3";
and now echo that json
?>

thanks 🙁

  • 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-13T14:01:10+00:00Added an answer on June 13, 2026 at 2:01 pm

    why this is not work i get alert (error:undifined)

    You have to tell jQuery that the response is JSON. You can do so by either passing 'json' as forth parameter to $.post [docs] or by setting the correct response headers in PHP:

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

    Alternatively you can parse the response yourself with jQuery.parseJSON [docs].

    how i can get some result from that php file when its have other output like this

    There is no easy way. The response is not valid JSON anymore, so you have to parse it yourself somehow. You should avoid doing this and return everything as JSON.

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

Sidebar

Related Questions

I am facing problems in sending json response to php that I get from
I search the web alot and didn't find c++ function that replace xml Special
I search the web alot and didn't find js function that replace xml Special
I've seen alot of tutorials on search with php and mysql, but im having
Hey i want to list the results from a google search, i saw that
I have this page that lists info from my mysql database. It requires an
I have search a lot for iPhone material to get started, but I found
I did a lot search already but couldn't find a straight anwser. I have
There's a lot of software that will take a search string and find all
I have code which takes in data from Flickrs Rest service and populates a

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.