MiniProfiler Throwing Unexpected Token with Ajax.BeginForm
Asked Answered
S

1

6

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!

Statistics answered 4/12, 2013 at 14:50 Comment(3)
what do you see in your Developer Tools within your browser... does the response from the server reflect those unexpected results or does it look correct?Grivet
The comment in miniprofiler function says it should get something like: ["008c4813-9bd7-443d-9376-9441ec4d6a8c","16ff377b-8b9c-4c20-a7b5-97cd9fa7eea7"] but in my case it's getting "["6de0e02c-e694-4d8a-ac22-ea6a847efe0e","970f6640-fe5b-45d9-bf59-c916b665458d"], ["6de0e02c-e694-4d8a-ac22-ea6a847efe0e","970f6640-fe5b-45d9-bf59-c916b665458d"]"Statistics
I am not much aware of MiniProfiler but there is bug there which might related.. code.google.com/p/mvc-mini-profiler/issues/detail?id=99Lennyleno
H
0

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

Wait for next update.

Hydrolysate answered 13/12, 2013 at 5:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.