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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:49:52+00:00 2026-06-17T20:49:52+00:00

I am trying to get the success response to send the values from ajax

  • 0

I am trying to get the success response to send the values from ajax into their respective fields. For whatever reason I can’t get that to happen. In the success section I am issuing a “alert(responseObject)” in which the results are in the attached image. So the data is coming back just as I want it, but I can’t get the values to populate into the matching fields.

$(document).ready(function() {
    function myrequest(e) {
        var man_part_number = $('#man_part_number').val();
        $.ajax({
            method: "GET",
            url: "includes/autofill.php",

            data: {
                man_part_number: man_part_number
            },
            success: function(responseObject) {
                alert(responseObject);
                //This alert response results is in attached image
                $('#manufacture').val(responseObject.manufacture);
                $('#model').val(responseObject.model);
                $('#type').val(responseObject.type);
            },
            failure: function() {
                alert('fail');
            }
        });
    }

    $('#fetchFields').click(function(e) {
        e.preventDefault();
        myrequest();
    });
});

<button type="button" id="fetchFields">Fetch</button>

<input type="text" name="manufacture" id="manufacture" />
<input type="text" name="model" id="model" />
<input type="text" name="type" id="type" />

Return AJAX Code

  • 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-17T20:49:53+00:00Added an answer on June 17, 2026 at 8:49 pm

    The string returned is not JSON. Look at the end of your string in the Alert box. It has “test”. That means that the response is parsed as text by jQuery, since you don’t specify the dataType option. If you did specify it as “JSON”, it would fail because having “test” next to “{…}” is invalid JSON. I guess the point is that you need to return valid JSON, and if you are indeed expecting JSON back, set the dataType option for the $.ajax call to be “JSON”. At the same time, your server should be setting the proper header in the response anyways. It’s still better (sometimes) to specify the dataType option.

    By default, if you don’t specify the dataType option, jQuery will check the headers of the response to get the Content-Type. If it matches a valid type for “JSON”, “HTML”, “Text”, “XML”, or a few others, it will attempt to parse it by that. I’m betting your response doesn’t have its headers set properly, otherwise jQuery would’ve attempted to convert it to JSON and failed. It’s probably being returned as plain text, so jQuery sees that and parses it as text…which is why it parses fine. But the responseObject you’re referencing is not an Object as you expect, because you don’t follow these procedures to ensure proper parsing.

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

Sidebar

Related Questions

Im trying to get a response from a function in a webservice but i
I'm trying to get a PHP array with AJAX and turn it into a
I'm trying to use AJAX to send values to PHP file, which then updates
I'm trying to send XML doc to server from client. But when server get
I am trying to get response message from jsonp error callback in angularjs, but
I am trying to send a from's content over AJAX POST request, using jquery.
I've been trying to get a basic OAuth interaction working without success. There are
I'm trying get the visible portion of UIImage from an UIImageView . UIImageView takes
Trying to get this expression to work, can someone look at it and tell
How to send GET and POST parameters with jQuery AJAX request simultaneously? I am

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.