Question

I have this:

$.ajax({
    url:        '/autocomplete',
    type:       'GET',
    dataType:   'json',
    success:    function(data) {
        alert(data);
    }
});

and trying to mock it with:

$.mockjax({
    url:            '/autocomplete',
    type:           'GET',
    responseTime:   50,
    responseText:    function() {
        this.responseText = {info: 'Merge !!!'};
    }
});

I'm getting NULL as a response from mocjax.

What am I doing wrong? How can I use the response function in mockjax

Was it helpful?

Solution

Instead of

responseText

it should be just

response

So, the correct version is:

response:    function() {
    this.responseText = {info: 'Merge !!!'};
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top