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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T02:09:28+00:00 2026-05-30T02:09:28+00:00

In the post How to use Ajax.BeginForm MVC helper with JSON result? Joel references

  • 0

In the post How to use Ajax.BeginForm MVC helper with JSON result? Joel references a solution as follows:

function onTestSuccess(data, status, xhr) { 

    console.log("data", data); 
    console.log("xhr", xhr); 
    console.log("status", status); 

    // Here's where you use the JSON object 
    //doSomethingUseful(data); 
} 

How do I reference elements in the JSON object “data” in my code?
My console log shows the following:
LOG: data{“success”:true,”uri”:”/Image/Confirm2?category=foo”}

I am trying to use the value of “uri” in my jquery code. I’ve tried:

console.log(“uri”, data.uri);

but get the folowing as a result:

LOG: datauriundefined

  • 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-05-30T02:09:30+00:00Added an answer on May 30, 2026 at 2:09 am
    function onTestSuccess(data, status, xhr) { 
        var uri = data.uri;
        // uri = '/Image/Confirm2?category=foo' at this stage 
        // so you could do something useful with it
    } 
    

    Also for this to work you need to use the OnSuccess="onTestSuccess" setting in your AjaxOptions when setting up the Ajax.BeginForm instead of OnComplete="onTestSuccess".


    It turns out that the problem is with your controller action in which you specified incorrect Content-Type of text/html.

    So instead of:

    String uri = Url.Action("Confirm2", "Image", new RouteValueDictionary(new { category = "foo" })); 
    return Json(new { success = true, uri = uri }, "text/html");
    

    you should use:

    String uri = Url.Action("Confirm2", "Image", new RouteValueDictionary(new { category = "foo" })); 
    return Json(new { success = true, uri = uri });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In ASP.NET MVC 3 application I use Ajax.BeginForm to post writed text to controller.
Assume we use jQuery.ajax() to POST data with two parameters, game_id and player_id .
I'm trying to use jquery.Ajax to post data to an ASP.NET MVC2 action method
When i use jquery's $.post ajax function, page freezes for 2-3 seconds and then
I use Ajax (jQuery) and the POST method to update data in the database.
How do i use ajax to send POST requests to the server instead of
I am trying to use .ajax() to post a People object to a MVC2
I need to use the $.ajax() call within jQuery to post a little bit
I have a simple div that i use to trigger an ajax post. I
If you use POST to send FORM data to a PHP page, are the

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.