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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T22:12:54+00:00 2026-06-04T22:12:54+00:00

Using success: function(data) in the jquery code, when I retrieve the data from PHP,

  • 0

Using success: function(data) in the jquery code, when I retrieve the data from PHP, I can’t display the parameter str"=>$dataString in the jQuery code.

success: function(data) {
    alert(data[0]);
    $("#display").html(data[str]);
}

ajax.php:

<?php
  if (isset($_POST['dataString'])) {
    $dataString=$_POST['dataString'];
    echo (array("str"=>$dataString));
  } else {$_POST['dataString']="";}
?>

    <html>
    <head>
    <link rel="stylesheet" type="text/css" href="./public/stylesheets/stylesheets.css"  >
    <script type="text/javascript" src="./public/js/jquery-1.7.1.min.js"></script>
    <script type="text/javascript" >
    $(document).ready(function() {
      var dataString;
      $("#valueforajax").blur(function() {
        dataString = $.trim(this.value);
        if (dataString){
        // until here it works
          $.ajax({
            type: "POST",
            dataType: 'html',
            url: "ajax.php",
            data: 'dataString=' + dataString,
            //{"dataString": dataString}
            cache: false,
            success: function(data) {
              alert(data[0]);
              $("#display").html(data[str]);
            }
          });
        }
      });
    });
  </script>
  <meta http-equiv="Content-Type" content="text/html; charset=windows-1255">
  <title>mange panel</title>
  </head>
  <body>
    <br>Type value for test in ajax<input id="valueforajax" type=text name='ajaxtest'>
    <div id="display">show</div>
  </body>
</html>
  • 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-04T22:12:56+00:00Added an answer on June 4, 2026 at 10:12 pm

    ajax.php

    <?php
      if (isset($_POST['dataString'])) {
         echo $_POST['dataString'];
         exit(0);  //this will supress html output
      }
      else {
       //do nothing
      }
    ?>
    

     $.ajax({
        type: "POST",
        dataType: 'html',
        url: "ajax.php",
        data: 'dataString=' + dataString, //{"dataString": dataString}
        cache: false,
        success: function(data)
        {
           alert(data);
           $("#display").html(data);
           }
        });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this jquery code: $.ajax({ url:'ajax/windowshop.php', context:'#windowShop', success:function(data){ $('#windowShop').append(data); } }) I want
I am using jQuery.ajax(...) to retrieve JSON data from an ASP.NET MVC service. When
Here is the code I'm currently using: $.ajax({ success: function(){ $('.post_container').append('test <br />'); }
I'm using a jQuery ajax json call to retrieve a 3 dimensional PHP array
I am using following jQuery code to submit a form via AJAX. jQuery('form.AjaxForm').submit( function()
I'm trying to retrieve JSON data from servlet and display in html. I was
Using jQuery Ajax to fetch data from local server: it works well with IE8
I have tried to use the following code to retrieve the data from the
When I try to get the response from a php file using Jquery ajax,
I currently using the change function from jQuery. The change event is only fired

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.