MiniProfiler Throwing Unexpected Token with Ajax.BeginForm

343 Views Asked by At

I'm using MiniProfiler on an MVC 4 app. We have a view being rendered in a modal (using the Colorbox jquery plugin). That view then has a partial view in it with an ajax form that looks like this:

@using(Ajax.BeginForm("<action name>", "<controller name>", new {area="<area name>"}, new AjaxOptions
    {
        UpdateTargetId = "modal-body",
        InsertionMode = InsertionMode.Replace,
        HttpMethod = "POST"
    }))
{
    <html for form here>
}

When we submit the form it returns the same partial view to overwrite this whole section on the view. When it's posted MiniProfiler throws an error: SyntaxError: Unexpected token ,

This happens in this function:

var jQueryAjaxComplete = function (e, xhr, settings) {
            if (xhr) {
                // should be an array of strings, e.g. ["008c4813-9bd7-443d-9376-9441ec4d6a8c","16ff377b-8b9c-4c20-a7b5-97cd9fa7eea7"]
                var stringIds = xhr.getResponseHeader('X-MiniProfiler-Ids');
                if (stringIds) {
                    var ids = typeof JSON != 'undefined' ? JSON.parse(stringIds) : eval(stringIds);
                    fetchResults(ids);
                }
            }
        };

It's expecting to a json array of guids, but instead it's getting the array twice, like this:

"["6de0e02c-e694-4d8a-ac22-ea6a847efe0e","970f6640-fe5b-45d9-bf59-c916b665458d"], ["6de0e02c-e694-4d8a-ac22-ea6a847efe0e","970f6640-fe5b-45d9-bf59-c916b665458d"]"

This causes it to puke when it tries to parse the array. I'm not sure why the array is getting duplicated. Any help would be greatly appreciated. Thanks!

1

There are 1 best solutions below

0
On

This a miniprofiler bug https://github.com/MiniProfiler/ui/pull/5

Wait for next update.