PDA

View Full Version : [CLOSED] Javascript Error



adelaney
Jun 18, 2012, 2:36 PM
I am experienceing a javascript error in the loading and initilization of the resource. Specifically, the error is this: "p is null","http://localhost:1858/extjs/ext-all-js/ext.axd?v=13055",21

I don't know when the error started or if it is because I am not initializing something correctly, but how would you suggest that I go about debugging this in the most effective manner since the javascript is compressed and obsfucated? I used jsbeautifier to make the code readable and found this (at line 30):


Ext.apply = function (o, n, q) {
if (q) {
Ext.apply(o, q)
}
if (o && n && typeof n === "object") {
var p, m, l;
for (p in n) {
o[p] = n[p]
}
if (b) {
for (m = b.length; m--;) {
l = b[m];
if (n.hasOwnProperty(l)) {
o[l] = n[l]
}
}
}
}
return o

but I am not sure where to go from here. What do you suggest?

Daniil
Jun 18, 2012, 2:52 PM
Hi,

I can't see the line #30 in the code.

I used jsbeautifier to make the code readable and found this (at line 30):


Ext.apply = function (o, n, q) {
if (q) {
Ext.apply(o, q)
}
if (o && n && typeof n === "object") {
var p, m, l;
for (p in n) {
o[p] = n[p]
}
if (b) {
for (m = b.length; m--;) {
l = b[m];
if (n.hasOwnProperty(l)) {
o[l] = n[l]
}
}
}
}
return o


I can suggest:

1. Set up

<ext:ResourceManager runat="server" ScriptMode="Debug" />
on the page or

<extnet scriptMode="Debug" />
in Web.config.

It will cases the JS "debug" (well-formatted) scripts will be loaded.

2. Use VisualStudio + Internet Explorer to debug JavaScript. Internet Explorer can catch the JavaScript error and you can use Visual Studio instance to debug.

adelaney
Jun 18, 2012, 6:45 PM
I have a little more information, but hoping you can help some more. It appears that the error is here:
"url is null","http://localhost:1858/extjs/ext-all-debug-js/ext.axd?v=13055",813


urlAppend : function(url, string) {
if (!Ext.isEmpty(string)) {
return url + (url.indexOf('?') === -1 ? '?' : '&') + string;
}

return url;
},

It doesn't impede the processing fo the rest of the script. However, I don't know what is calling this function. Can you give me a hint as to what may call this bit of code? It seems that the grid is what is triggering the error, as removing the grid eliminates the error. However, as stated, it doesn't prevent the grid from displaying. Any ideas?

Daniil
Jun 18, 2012, 6:49 PM
I guess you have something like this:

<ext:Panel runat="server">
<Loader runat="server" Mode="Frame" />
</ext:Panel>

So, the Loader with no Url.

If yes, please set up

AutoLoad="false"
for the Loader.

Example

<ext:Panel runat="server">
<Loader runat="server" Mode="Frame" AutoLoad="false" />
</ext:Panel>

adelaney
Jun 18, 2012, 7:04 PM
I didn't have exaclty what you described, but I had this:

.Loader(New Ext.Net.ComponentLoader() With {.Enabled = True, .ClientIDMode = ClientIDMode.Static, .AutoLoad = True, .AutoDataBind = True, .Mode = LoadMode.Data}) _

As you can see, I did have the autoload set to true. I changed it to false, and the error is resolved. Since I have URLs set up in the proxy, I am not sure why it was throwing a URL error. Will you explain that to me?

Thanks for the help.

Vladimir
Jun 18, 2012, 7:24 PM
I am not sure what proxy do you mean
Loader is not related with any proxy. You have to define url or direct method for loader

Which widget is used that Loader?

adelaney
Jun 18, 2012, 7:40 PM
Hmm....Ok. I guess I don't fully understand how everything gets transferred back and forth. The loader is for a grid. The grid has a proxy set up for its store. The grid also has some complex filtering that we chose to do outside of the grid functionality as it was too complex via javascript and so we simply opted for Ajax calls back to the controller and then reload the grid "from scratch," which is why the loader became necessary, if I am not mistaken - it was a support/tech help item from you guys.



Here is the store and loader:

.
Store(Sub(str)
str.Add(Html.X.Store().ID("tmStore").AutoLoad(True) _
.Model(Sub(mdl)
mdl.Add(Html.X().Model.Fields(Sub(fields)
fields.Add(Html.X.ModelField.Name("CWTeamID").Type(ModelFieldType.Int))
fields.Add(Html.X.ModelField.Name("Name"))
fields.Add(Html.X.ModelField.Name("DrafterEmployeeID").Type(ModelFieldType.Int))
fields.Add(Html.X.ModelField.Name("ReviewerEmployeeID").Type(ModelFieldType.Int))
fields.Add(Html.X.ModelField.Name("CorrespondentEmployeeID").Type(ModelFieldType.Int))
fields.Add(Html.X.ModelField.Name("QAReviewerEmployeeID").Type(ModelFieldType.Int))
End Sub).ID("mdlTeam").Name("mdlTeam"))
End Sub) _
.Proxy(Sub(proxy)
Dim prxy As New Ext.Net.AjaxProxy()
With prxy
.API.Create = Url.Content("~/Assignments/_AddTeam/")
.API.Read = Url.Content("~/Assignments/_GetTeams/") + MvcApplication.CurrentApplicationUser.EmployeeID.T oString()
.API.Update = Url.Content("~/Assignments/_EditTeam")
.API.Destroy = ""
.Json = True
.Reader.Add(New Ext.Net.JsonReader() With {.Root = "Data", .AutoDataBind = True})
End With

proxy.Add(prxy)
End Sub) _
.RemotePaging(False) _
.PageSize(15))
End Sub) _
.Loader(New Ext.Net.ComponentLoader() With {.Enabled = True, .ClientIDMode = ClientIDMode.Static, .AutoLoad = False, .AutoDataBind = True, .Mode = LoadMode.Data}) _

As may be obvious, we use the proxy calls for the adding/editing of records. Hopefully, this makes sense. If not, I can try to clarify more.

Daniil
Jun 18, 2012, 8:54 PM
if I am not mistaken - it was a support/tech help item from you guys.

I don't think so. Or, maybe, there is some misunderstanding.

GridPanel should gets its data from the Store. And I don't think using the Loader for GridPanel is a good approach.

Please clarify the initial requirement with more details. Maybe, we could suggest something better.