Question: I am trying to do a Jquery .ajax post to an MVC action. This Action then should return a JsonResult. Currently, this JsonResult is "", however I want the return object to be filled with Json. Any help? Thanks!

```
$.ajax({
  type: 'post',
  dataType: 'json',
  url: url,
  contentType: "application/json; charset=utf-8",
  traditional: true,
  data: JSON.stringify({ source: source }),
  success: function (data) {
debugger;
  }
});

public ActionResult PublishSource(string source)
{
    return Json(new {data = "test"});
}

```

Edit: Here's my current code below. Still having returned data in success method of .ajax being null.

```
$.ajax({
        type: 'post',
        cache: false,
        url: url,
        contentType: "application/json",
        success: function (data) {
            debugger;
        }
    });

public JsonResult PublishSource()
{
    var data = "test";
    return Json(data, JsonRequestBehavior.AllowGet);
}

```

Answer: 
You have done it correctly, just do 

```
console.log(foo.bar);

```

and you will see what you want. You saw `{}` in some browser just because the way it is displayed in some browser. On Safari for example, you can "dig into" the object and see the `bar` when you follow the `__proto__` chain.

`bar` is not a `foo`'s "own property" this way. In order for it to be `foo`'s own property, you need to set `foo.bar` so that it is `foo`'s own property.

Explanation:

1. `foo` is a variable which is a reference to an object (let's call this object A).
2. This object has a "[[Prototype]] internal property" or `__proto__` property as seen in the Firefox or Chrome browser.
3. `foo.__proto__` is a reference to an object, (let's call this object B), which is exactly what Foo.prototype is a reference to.
4. when you say `foo.bar`, first the JavaScript engine looks in object A as to whether the property `bar` exists, and since it does not, it will follow `foo.__proto__` and look at object B, and finds it, and return the result to you.

Note that [`foo.__proto__` is deprecated](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/proto). It is not a standard, but currently works in Chrome, Firefox, and Safari to experiment with your code, but on IE and in general, you need to do `Object.getPrototypeOf(foo)` to see it.
> 
> In other words, is it possible to preset a prototype and have the properties be exposed as ownProperties to the object instance of that prototype?
> 
> 
> 

You can't do it directly but [Proxy](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy) object can intercept `Object.getOwnPropertyNames` and similar.

If you want to support browsers other than Firefox, you have to write your own function for retrieving properties (you can also override `Object.getOwnPropertyNames` but I don't recommend it - *don't modify object you don't own*).