I am using ASP.NET MVC 4 in VS2012.
I am using bundles to minify my JavaScript code.
My bundle code is:
bundles.Add(new ScriptBundle("~/bundles/inline").Include("~/Scripts/inline/_layout_inline.js"));
JavaScript source looks like this:
function requestPurchaseCompanies()
{
var urlStr = '/Search/PurchaseSelectedCompanys';
$.ajax({
url: urlStr,
dataType: 'json',
type: 'POST',
error: function (result, status, error) {
var message = JSON.parse(result.responseText);
parsePurchaseError(message);
},
success: function (data) {
// get the result and do some magic with it
var message = data.Message;
if (window.location.href.indexOf('page=') < 0) {
var url = '/Search/PagingDisplay';
var params = '?page=1';
window.location = 'http://' + window.location.host + url + params;
} else {
window.location = window.location;
}
}
});
}
Note the line : error: function (result, status, error) {
Here is the rendered minified JavaScript:
function requestPurchaseCompany(n, t, i, r) {
var u = undefined,
f, e, o, s, h;
n != null && i == "SearchResults" ? (f = $(n).closest("div.result")[0], f && f != "undefined" && (e = $(f).children("span[id=SelectDuns]")[0], e && e != "undefined" && (o = $(e).children("input:hidden")[0], o && o != "undefined" && (u = new CompanySelectState, u.CompanyID = o.value)))) : t != undefined && (u = new CompanySelectState, u.CompanyID = t), u && u != undefined && (s = "/Search/PurchaseCompany", h = JSON.stringify(u), $.ajax({
url: s,
type: "POST",
dataType: "json",
data: h,
contentType: "application/json; charset=utf-8",
error: function (n) {
var r = JSON.parse(n.responseText);
parsePurchaseError(r)
},
success: function (t) {
var e = t.Message,
u, f;
t.State == !0 && $(n).attr("disabled", ""), n != null && i == "SearchResults" ? window.location.href.indexOf("page=") < 0 ? (u = "/Search/PagingDisplay", f = "?page=1", window.location = "http://" + window.location.host + u + f) : window.location = window.location : window.location = window.location, r != undefined && r == !0 && window.opener != undefined && window.opener.location != undefined && window.opener.location.reload()
}
}))
}
NOTE line 10: error:function(n){
So it started out as:
error: function (result, status, error) {
and got rendered as:
error:function(n){
The issue with this is that the minified code that has one parameter treats that parameter as the error parameter not the XMLHttpRequest that I require.
How do I fix this?