Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
164
rated 0 times [  166] [ 2]  / answers: 1 / hits: 29166  / 13 Years ago, fri, october 21, 2011, 12:00:00

I have a number of clickable objects on the screen that represent objects within a piece of software being interfaced through a COM component.



When I click on an object I send the name of the object, the session ID and the command I want to run.



The code for the particular command that I'm trying to implement is a C# based ASP.NET page:



case myClick:
dynamic simObj = S8COM.get_SimObject(Request[id]);
responseData = {name: + simObj.Name.ToString() + ,countInRoutes: + simObj.CountInRoutes.ToString() + ,countOutRoutes: + simObj.CountOutRoutes.ToString() + ,index: + simObj.Index.ToString() + ,capacity: + simObj.Capacity.ToString() + ,completed: + simObj.Completed.ToString() + ,routeOutMethod: + simObj.RouteOutMethod.ToString() + };
break;


This works fine for some objects, but not others, throwing an Uncaught SyntaxError: Unexpected number exception.



The JS I use to call this particular function is:



S8Web.Requestmanager.makeRequest({ data: { command: myClick, id: aItem.id }, async: true, callback: function(data){
alert(data.CountInRoutes); //Do a vardump of the response
}});


A couple of responses as well, the first one works fine, whereas the second throws the Unexpected Number exception:



jsonp1319203225074({name:Start,countInRoutes:0,countOutRoutes:1,index:5,capacity:0,completed:0,routeOutMethod:4});

jsonp1319203225066({name:Process 1,countInRoutes:1,countOutRoutes:1,index:1,capacity:1,completed:0,routeOutMethod:1});


The only thing I can see that could possibly affect the outcome is the whitespace between Process and 1. Is that what is throwing this error?


More From » jquery

 Answers
10

You very well may simply be having a problem with improperly closed quotes.



Example:



<a href='#' onclick=doStuff('joe, '2844')>click here</a>


Since the first parameter isn't closed properly, it's being interpreted as 'joe, '. That leaves 2844' as the rest of the function call, without a leading quote. This circumstance will throw the Unexpected Number error.


[#89499] Wednesday, October 19, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
andreguym

Total Points: 125
Total Questions: 112
Total Answers: 103

Location: Wallis and Futuna
Member since Tue, Mar 30, 2021
3 Years ago
;