htmlfile: Unexpected call to method or property access Error in jquery-1.5.1.min.jshttp://forums.asp.net/t/1797466.aspx/1?htmlfile+Unexpected+call+to+method+or+property+access+Error+in+jquery+1+5+1+min+jsFri, 27 Apr 2012 23:11:56 -040017974664953660http://forums.asp.net/p/1797466/4953660.aspx/1?htmlfile+Unexpected+call+to+method+or+property+access+Error+in+jquery+1+5+1+min+jshtmlfile: Unexpected call to method or property access Error in jquery-1.5.1.min.js <p>Im not sure that this isnt related to a Windows Update that was done late last week, as I havent had time this week to be in my app. However, I know this worked before, but suddenly I am getting the error htmlfile: Unexpected call to method or property access. in jquery-1.5.1.min.js when the following script is run:</p> <pre class="prettyprint">$(&quot;#PhoneListDrops&quot;).bind('change', function () { var name = $(&quot;#PhoneListDrops &gt; option:selected&quot;).attr(&quot;value&quot;); var label = $(&quot;#PhoneTypeAgentLabel&quot;); if (name == 'ACD') { $.getJSON (&quot;/Connections/GetAgentSup&quot;, function (newdata, sel) { var newitems = ''; $.each(newdata, function (z, agents) { var selected = ''; if (agents.Selected) { selected = ' checked=&quot;checked&quot; '; } newitems &#43;= &quot;&lt;input type='radio' name='Sup_Agent' value='&quot; &#43; agents.Value &#43; &quot;' &quot; &#43; selected &#43; &quot; /&gt;&quot; &#43; agents.Text; }); // end for each $(&quot;#PhoneTypeAgent&quot;).html(newitems); }); // end phonelistdrops change label.show(); } // end if = ACD else { // we need to force a blank into the radio button if they select, then unselect ACD var newitems = ''; newitems &#43;= &quot;&lt;input type='radio' name='Sup_Agent' value='' /&gt;&quot;; $(&quot;#PhoneTypeAgent&quot;).html(newitems); label.hide(); } });</pre> <p></p> <p>If I comment out the newitems line so it doesnt try to create the radio buttons, the script no longer generates the error. This only occurs when using IE 8. I have run in Google Chrome (which shows no html errors) and Firefox and the code runs fine and the radio buttons are rendered as they should be.</p> <p>Any ideas on what might be causing this and how I might fix it?</p> 2012-04-26T20:02:40-04:004953669http://forums.asp.net/p/1797466/4953669.aspx/1?Re+htmlfile+Unexpected+call+to+method+or+property+access+Error+in+jquery+1+5+1+min+jsRe: htmlfile: Unexpected call to method or property access Error in jquery-1.5.1.min.js <p></p> <blockquote><span class="icon-blockquote"></span> <p></p> <p>Any ideas on what might be causing this and how I might fix it?</p> <p></p> </blockquote> <p></p> <p>I don't know what the problem is, but have you tried a newer version of jQuery? There are always bugs here &amp; there with jQuery so perhaps it's something that is fixed in a newer version.</p> <p></p> 2012-04-26T20:08:34-04:004953753http://forums.asp.net/p/1797466/4953753.aspx/1?Re+htmlfile+Unexpected+call+to+method+or+property+access+Error+in+jquery+1+5+1+min+jsRe: htmlfile: Unexpected call to method or property access Error in jquery-1.5.1.min.js <p>It would help to know which line is causing the error.</p> 2012-04-26T21:13:34-04:004953897http://forums.asp.net/p/1797466/4953897.aspx/1?Re+htmlfile+Unexpected+call+to+method+or+property+access+Error+in+jquery+1+5+1+min+jsRe: htmlfile: Unexpected call to method or property access Error in jquery-1.5.1.min.js <p>I thought I indicated the line - it is the line where I am building the dyanmic radio buton list:</p> <p>newitems <span class="pun">&#43;=</span><span class="pln"> </span><span class="str">&quot;&lt;input type='radio' name='Sup_Agent' value='&quot;</span><span class="pln"> </span><span class="pun">&#43;</span><span class="pln"> agents</span><span class="pun">.</span><span class="typ">Value</span><span class="pln"> </span><span class="pun">&#43;</span><span class="pln"> </span><span class="str">&quot;' &quot;</span><span class="pln"> </span><span class="pun">&#43;</span><span class="pln"> selected </span><span class="pun">&#43;</span><span class="pln"> </span><span class="str">&quot; /&gt;&quot;</span><span class="pln"> </span><span class="pun">&#43;</span><span class="pln"> agents</span><span class="pun">.</span><span class="typ">Text</span><span class="pun">;</span><span class="pln">&nbsp;</span></p> <p><span class="pln">If I comment that line out, the error goes away. However, if I run this in Firefox or Chrome, there is no error and the radio buttons are properly rendered.</span></p> <p><span class="pln">I tried installing the latest qJuery (1.7.2) and that give an object not found error - still trying to figure out which line it doesn't like.</span></p> <p><br> <br> </p> 2012-04-26T23:36:55-04:004953966http://forums.asp.net/p/1797466/4953966.aspx/1?Re+htmlfile+Unexpected+call+to+method+or+property+access+Error+in+jquery+1+5+1+min+jsRe: htmlfile: Unexpected call to method or property access Error in jquery-1.5.1.min.js <p>I suspect your JSON that your returning is malformed and contains a trailing comma.&nbsp; Can you post what the JSON result looks like?&nbsp; It's easiest to use firebug in Firefox or Inspector in Chrome, both of those should be able to see the ajax call.</p> <p></p> 2012-04-27T01:41:05-04:004953999http://forums.asp.net/p/1797466/4953999.aspx/1?Re+htmlfile+Unexpected+call+to+method+or+property+access+Error+in+jquery+1+5+1+min+jsRe: htmlfile: Unexpected call to method or property access Error in jquery-1.5.1.min.js <p>The results of this JSON call:</p> <pre class="prettyprint">$.getJSON (&quot;/Connections/GetAgentSup/&quot;, function (newdata, sel)</pre> <p>returns this for newdata, sel - which appears correct to me - there are 2 records and ACD is selected:</p> <pre class="prettyprint">data = [Object { Selected=true, Text="ACD", Value="ACD"}, Object { Selected=false, Text="PBX", Value="PBX"}] sel = "success"</pre> <p>and the value of newitems, which is the radio buttons I'm building from the JSON results is as follows:</p> <pre class="prettyprint">"&lt;input type='radio' name='Sup_Agent' value='Agent' checked="checked" /&gt;Agent&lt;input type='radio' name='Sup_Agent' value='Supervisor' /&gt;Supervisor"</pre> <p><br> <br> <br> </p> 2012-04-27T02:44:18-04:004954004http://forums.asp.net/p/1797466/4954004.aspx/1?Re+htmlfile+Unexpected+call+to+method+or+property+access+Error+in+jquery+1+5+1+min+jsRe: htmlfile: Unexpected call to method or property access Error in jquery-1.5.1.min.js <p>Not valid JSON.</p> <p></p> 2012-04-27T02:58:07-04:004954013http://forums.asp.net/p/1797466/4954013.aspx/1?Re+htmlfile+Unexpected+call+to+method+or+property+access+Error+in+jquery+1+5+1+min+jsRe: htmlfile: Unexpected call to method or property access Error in jquery-1.5.1.min.js <p>I believe the JSON you are looking for is:</p> <pre class="prettyprint">data = [{ &quot;Selected&quot;:true, &quot;Text&quot;:&quot;ACD&quot;, &quot;Value&quot;:&quot;ACD&quot;}, { &quot;Selected&quot;:false, &quot;Text&quot;:&quot;PBX&quot;, &quot;Value&quot;:&quot;PBX&quot;}]; sel = &quot;success&quot;;</pre> <p>Note the removal of the words "Object", the ='s are changed to :, property/attribute names are wrapped in ", and ;'s are placed at the end of the statements.&nbsp; Not too sure about the ;'s being necessary as the whole thing isn't a single JSON result either since it looks like it's sending back two variables instead of a single result with both wrapped, which would look more like:</p> <pre class="prettyprint">{ "data":[ { "Selected":true, "Text":"ACD", "Value":"ACD" }, { "Selected":false, "Text":"PBX", "Value":"PBX" } ], "sel":"success" }</pre> <p><br> <br> <br> </p> 2012-04-27T03:12:05-04:004955124http://forums.asp.net/p/1797466/4955124.aspx/1?Re+htmlfile+Unexpected+call+to+method+or+property+access+Error+in+jquery+1+5+1+min+jsRe: htmlfile: Unexpected call to method or property access Error in jquery-1.5.1.min.js <p>If the JSON was not valid, why would this work in every other browser except for IE 8 though? The data returned from the JSON is properly parsed by Firefox and Chrome.</p> 2012-04-27T14:32:36-04:004955131http://forums.asp.net/p/1797466/4955131.aspx/1?Re+htmlfile+Unexpected+call+to+method+or+property+access+Error+in+jquery+1+5+1+min+jsRe: htmlfile: Unexpected call to method or property access Error in jquery-1.5.1.min.js <p>I don't know if this is your issue, but IE's object literal parsing is much more strict that FF/Chrome. So if they're using that same engine for JSON parsing (which would make sense) then perhaps there would be a difference.</p> <p></p> 2012-04-27T14:35:58-04:004955214http://forums.asp.net/p/1797466/4955214.aspx/1?Re+htmlfile+Unexpected+call+to+method+or+property+access+Error+in+jquery+1+5+1+min+jsRe: htmlfile: Unexpected call to method or property access Error in jquery-1.5.1.min.js <p>You can refer to references here: <a title="http://json.org" href="http://json.org"> http://json.org</a> or <a title="http://en.wikipedia.org/wiki/Json" href="http://en.wikipedia.org/wiki/Json"> http://en.wikipedia.org/wiki/Json</a>, you can try some online json validators like this one: <a title="http://jsonlint.com/" href="http://jsonlint.com/">http://jsonlint.com/</a> or this one <a title="http://jsonformatter.curiousconcept.com/" href="http://jsonformatter.curiousconcept.com/"> http://jsonformatter.curiousconcept.com/</a> they all say that JSON is not valid.&nbsp; Now as to why it works in every other browser (So long as your definition of every other browser is firefox and chrome), you will have to ask them why their JSON parsers are so shoddy.</p> <p>My question would be, why is firefox and chrome accepting garbage input and NOT throwing an error.&nbsp; That's a bug on their parts, as the ECMA-262 specification (The standard that defines javascript) clearly says that it MUST.</p> <p>Update: I just tested both the latest Firefox and the latest Chrome, and neither of these see this as valid JSON either.&nbsp; I'm not sure why they arn't throwing an error in your code, but atleast all three browsers agree it's not valid.</p> 2012-04-27T15:52:32-04:004955265http://forums.asp.net/p/1797466/4955265.aspx/1?Re+htmlfile+Unexpected+call+to+method+or+property+access+Error+in+jquery+1+5+1+min+jsRe: htmlfile: Unexpected call to method or property access Error in jquery-1.5.1.min.js <p>OK - here is where I'm building the JSON - what am I doing wrong?</p> <pre class="prettyprint">Dim agents As IQueryable(Of Connections) = Connections.GetSupAgent Dim selection As String Dim SaveVars As SaveSession = CType(TempData(&quot;PhoneAgent&quot;), SaveSession) If SaveVars Is Nothing Then selection = &quot;Agent&quot; Else selection = SaveVars.PhoneAgent End If Return Json(New SelectList(agents, &quot;Sup_Agent&quot;, &quot;Sup_Agent&quot;, selection), JsonRequestBehavior.AllowGet)</pre> <p>Here is GetSupAgent:</p> <pre class="prettyprint"> Public Shared Function GetSupAgent() As System.Linq.IQueryable(Of Connections) Dim l As New List(Of Connections) l.Add(New Connections() With {._Sup_Agent = "Agent", ._Sup_AgentID = "Agent"}) l.Add(New Connections() With {._Sup_Agent = "Supervisor", ._Sup_AgentID = "Supervisor"}) Return l.AsQueryable End Function</pre> <p><br> <br> </p> 2012-04-27T16:37:55-04:004955309http://forums.asp.net/p/1797466/4955309.aspx/1?Re+htmlfile+Unexpected+call+to+method+or+property+access+Error+in+jquery+1+5+1+min+jsRe: htmlfile: Unexpected call to method or property access Error in jquery-1.5.1.min.js <p>I think we may be going down the wrong path with the invalid JSON. My first view is displayed without any issues in IE 8 and I just debugged that page, as it contains drop-down boxes that are populated by JSON calls to the controller as well and the data parameter being returned appears the same way - I think maybe it's just the way the Firefox debugger is presenting the data or something?? Because the watch for data displays</p> <pre class="prettyprint">[Object { Selected=false, Text=&quot;SBS&quot;, Value=&quot;SBS&quot;}, Object { Selected=true, Text=&quot;Shared Services&quot;, Value=&quot;Shared Services&quot;}, Object { Selected=false, Text=&quot;SHD&quot;, Value=&quot;SHD&quot;}]</pre> <p>But the view this is on displays in IE 8 with absolutely no errors.</p> 2012-04-27T17:14:58-04:004955389http://forums.asp.net/p/1797466/4955389.aspx/1?Re+htmlfile+Unexpected+call+to+method+or+property+access+Error+in+jquery+1+5+1+min+jsRe: htmlfile: Unexpected call to method or property access Error in jquery-1.5.1.min.js <p>Ah yes, firefox is most likely reformatting the JSON in the debugger, which would make sense you said it worked in firefox and chrome, and it definately isn't a valid JSON string.</p> <p>Hmm... Are you adding a prototype function to Array or Object, or including a library that does like prototype.js?&nbsp; Try alerting the values you get back in the .each one at a time and see what it is returning.</p> 2012-04-27T18:50:46-04:004955454http://forums.asp.net/p/1797466/4955454.aspx/1?Re+htmlfile+Unexpected+call+to+method+or+property+access+Error+in+jquery+1+5+1+min+jsRe: htmlfile: Unexpected call to method or property access Error in jquery-1.5.1.min.js <p>OK - I just changed the code so that instead of building radio buttons on the fly, it built a drop-down box - and it works fine. So apparently it doesn't like something about building radio buttons on the fly?</p> 2012-04-27T19:37:00-04:004955610http://forums.asp.net/p/1797466/4955610.aspx/1?Re+htmlfile+Unexpected+call+to+method+or+property+access+Error+in+jquery+1+5+1+min+jsRe: htmlfile: Unexpected call to method or property access Error in jquery-1.5.1.min.js <p>Did some more playing and testing and have found the problem. I was using a &lt;placeholder&gt; for where the radio buttons should appear on my form - as soon as I changed those to use &lt;div&gt;, the radio buttons are dynamically created and no errors are returned in any of the browsers. Something apparently changed this - as the &lt;placeholder&gt; has been there since I wrote it and this was all working a week or so ago.</p> 2012-04-27T23:11:56-04:00