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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T21:06:55+00:00 2026-06-08T21:06:55+00:00

Good day guys, I’m using jQuery-form to submit a multipart form. This is my

  • 0

Good day guys, I’m using jQuery-form to submit a multipart form.

This is my PHP code:

foreach($addedData as $key => $value)
    $result[$key] = $value;

echo json_encode($result);

Javascript:

function showResponse(responseText){
   alert(responseText);
}
$('button').click(function(){
    $("form").ajaxForm({
        success: showResponse,
        clearForm: true,
    dataType: "json",
    contentType: "application/json; charset=utf-8"
    });
});

With this, the response was [object Object]. But when I removed these two lines:

dataType: "json",
contentType: "application/json; charset=utf-8"

The response became:

{"key1":"val1","key2":"va2","key3":"val3"}

My questions are: Do I really have to remove those two lines? And how can I get the values of the responseText using Json?

  • 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-08T21:06:56+00:00Added an answer on June 8, 2026 at 9:06 pm

    If you specify dataType: 'json' then your success callback function will be passed the object the JSON represents, rather than a JSON string. jQuery implicitly handles converting the responseText to the object for you, so you don’t have to do JSON.parse(responseText) for yourself. If the response isn’t valid JSON, the success callback won’t be executed; even if the AJAX request returned successfully.

    To get the values out, just use responseText like any other Javascript object; though you may want to give it a different name to make it clearer what it actually is.

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

Sidebar

Related Questions

Good day guys, I'm trying to submit a form with a file using jQuery
Good day guys, I've made a sweet favorites function with php mysql and ajax,
Good day guys, I don't know... why does not this query works: SELECT article.topic,
Good day guys. I'm using bloodshed devc++ as ide which, I believe, is using
Good day :) I am using jQuery's animate() on both opacity and height, on
Good Day Guys, I know this may sound like a stupid question. However, I
Good day guys, I am really nowhere to the guy who do PHP coding,
Good Day, Can someone confirm what was said at the bottom of this post
Good day, all. I know that this is a pretty basic question in terms
Good day everyone, this is one of those areas that is a little over

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.