I have a problem with my code, and have searched for hours what could be the fix, but with no luck. Tried many things myself, also with no luck. So here's my problem:

I have an JS function that creates a new 'Window', including all the DIV's, so everything is dynamically created. I have an AJAX request in my function, which gets data from a PHP file, and is supposed to put that data in the corresponding DIV which that same function creates. But I get the error:

```
Uncaught TypeError: Cannot set property 'innerHTML' of undefined

```

My code:

```
var proWindow = function(HEIGHT,WIDTH,TITLE,TYPE,ID){
this.max = false;
this.name = TITLE;
this.mMain = document.createElement("div");
this.mMain.className = "main";
this.appID = ID;
this.id = this.name + ID;
$.ajax({
    url: 'includes/getAppContents.php',
    type: 'GET',
    data: {thisAppID: this.appID},
})
.done(function(result) {
    var result = $.parseJSON(result);
    var code = (result['code']);
     this.mMain.innerHTML = code;
})
.fail(function() {
    //console.log("FAILED RETRIEVING CODE FOR APPLICATION");
})
.always(function() {
    //console.log("INITIALIZING APPLICATION");
});

```

The 'this' part of the code is completely lost in the AJAX brackets, which causes the problem, AJAX doesn't know what I mean with: "this.mMain", but how am I supposed to fix that?

Thanks,
-Tristan