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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T05:11:33+00:00 2026-06-17T05:11:33+00:00

I am trying to create a dynamic web page which requires no post back

  • 0

I am trying to create a dynamic web page which requires no post back and communicates with a server to get complex objects. I started out creating an AJAX enabled WCF Service, then writing some jquery to talk to the service. I got it working following this tutorial http://www.codeproject.com/Articles/132809/Calling-WCF-Services-using-jQuery.

I then realized I could use MVC a lone to do this, with the JsonResult type as the Action on a controller, following this tutorial: http://geekswithblogs.net/michelotti/archive/2008/06/28/mvc-json—jsonresult-and-jquery.aspx.

When I tried to leave the .cshtml page the way it was, and just plug in the different service (switching from WCF to MVC), my javascript started crashing (when it tries to evaluate response.length in the JS). I used the WebDevHelper tool to examine the Response Content of the JSON file and find a key difference.

The MVC JsonResponse gives me this result: ["anthony"]
The AJAX enabled WCF service gives me this: {"GetUserResult":["anthony"]}

The WCF method looks like this:

    [OperationContract]
    [WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Json)]
    string[] GetUser(string Id)
    { return new string[] { "foo", "bar" }; } 

The MVC method looks like this:

    public JsonResult GetUser(string Id)
    { return Json(new string[] { "foo", "bar" }); }

GetUser returns an array of strings (in this case it always returns a single item in the array).The method name on the WCF Service is called ‘GetUser’, but I don’t understand fully what I’m looking at, I have no clue why the WCF would provide different data then the MVC, and lastly, why would the javascript work fine evaluating result.length, but crash because it cannot find a length property when using the smaller MVC data? It seems JSON isn’t including the array information in the JsonResult?

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-17T05:11:34+00:00Added an answer on June 17, 2026 at 5:11 am

    I found the issue; the WCF AJAX enabled service returns the method name as an object that your return value lives inside. I tried changing the attribute WebMessageBodyStyle.Wrapped to WebMessageBodyStyle.Bare to fix this – but for some strange reason, it made my service unfindable? I think this is a config issue – but to get it working anyway, I changed it to WrappedRequest – which would give me a Bare response and the service worked as expected. No idea why the service would disssapear due to a small change like this though… pretty wacky

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

Sidebar

Related Questions

I am trying to create a dynamic 'page' listing for threads/comments using AJAX. in
I'm trying to create a dynamic datagrid in Flex. The data is coming back
I'm trying out some dynamic web page background generation using lines and text. Take
I'm trying to set up a web service. My approach has been: create Dynamic
I'm trying to create a dynamic webpage using include() in PHP. This PHP page
I'm trying to create a dynamic web project in eclipse, but my version of
I am trying to create my first dynamic site on windows server 2008 r2.
I have a dynamic php page which I need to call with a get
I am trying to create dynamic pages without creating new files and getting the
I am trying to create dynamic menus from the database using the following example

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.