Error Str.charat Is Not A Function
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn
Typeerror: D.charat Is Not A Function
more about Stack Overflow the company Business Learn more about hiring developers or word.charat is not a function datatables posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow text.charat is not a function Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up function result.charAt does not exist up vote 0 down
Typeerror: Cannot Read Property 'charat' Of Undefined
vote favorite I'm a newbie in javascript, and I don't really understand the error I'm having. I'm working on a MVC3 website, which has to monitor an embedded system. Here is the javascript code that is running : function GetTemp() { var test = "gTe"; $.ajax({ url: '@Url.Action("../Carte/Get")', type: 'GET', data: {test: test}, success: function (result) { if (result.charAt(4) == 'a') { $("#LumAct").text(result.substr(0, 4) + " %"); alert('a');
Angular Typeerror: Key.charat Is Not A Function
} ... And here is the c# action that returns a string public String Get(String test) { flag = TCPClient.SendData(test); if (flag == "1") { try { value = TCPClient.ReceiveData(); } catch { value = "Erreur"; } } else value = "Erreur"; return value; } The error I have is in firebug, which tells me : TypeError: result.charAt is not a function [Stopper sur une erreur] if (result.charAt(4) == 'a') { So, what haven't I understood? According to me, I'm using an ajx function that sends a httpGet to the controller, which responds with a string. In javascript, I can work on a string like I did. To use the string object, I haven't added any library. Should I have done that? I haven't found any information telling that. javascript asp.net share|improve this question edited Jan 10 '13 at 20:08 Mike 22.2k1262125 asked Jan 10 '13 at 18:03 Deblaton Jean-Philippe 4,89421643 1 Try setting dataType:'text', to prevent jQuery from converting your data. –Musa Jan 10 '13 at 18:17 add a comment| 2 Answers 2 active oldest votes up vote 2 down vote accepted Can you try this: if (String(result).charAt(4) == 'a') Also, as mentioned by @Musa, you should add a
here for a quick overview of the site javascript charat Help Center Detailed answers to any questions you might
Jquery Datatables
have Meta Discuss the workings and policies of this site About Us Learn more angular components about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users http://stackoverflow.com/questions/14264352/function-result-charat-does-not-exist Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up charAt coming back as undefined up vote 0 down vote favorite 1 I've http://stackoverflow.com/questions/27777841/charat-coming-back-as-undefined got the following function, however it's saying the charAt is undefined. The error is relating to the alert line. If i do alert(value) it gives me the value no problems. $scope.markAnswer = function(answerID, questionID) { if ($scope.containsObject(answerID, $scope.selectedAnswer)) { $scope.selectedAnswer.splice($scope.selectedAnswer.indexOf(answerID), 1); } else { $scope.selectedAnswer.push(answerID); } angular.forEach($scope.selectedAnswer, function(value, key) { alert(value.charAt(0)); if(questionID == res){ $log.info("questionID"); } }); } The following error: TypeError: undefined is not a function at http://127.0.0.1:9000/modules/core/controllers/home.js:57:25 at Object.forEach (http://127.0.0.1:9000/lib/angular/angular.js:325:18) at Scope.$scope.markAnswer (http://127.0.0.1:9000/modules/core/controllers/home.js:56:17) at http://127.0.0.1:9000/lib/angular/angular.js:10903:21 at http://127.0.0.1:9000/lib/angular-touch/angular-touch.js:441:9 at Scope.$eval (http://127.0.0.1:9000/lib/angular/angular.js:12811:28) at Scope.$apply (http://127.0.0.1:9000/lib/angular/angular.js:12909:23) at HTMLDivElement.
Learn Bootstrap Learn Graphics Learn Icons Learn How To JavaScript Learn JavaScript Learn jQuery Learn jQueryMobile Learn AppML http://www.w3schools.com/jsref/jsref_charat.asp Learn AngularJS Learn JSON Learn AJAX Server Side Learn SQL https://datatables.net/forums/discussion/10142/sdata-charat-error Learn PHP Learn ASP Web Building Web Templates Web Statistics Web Certificates XML Learn XML Learn XML AJAX Learn XML DOM Learn XML DTD Learn XML Schema Learn XSLT Learn XPath Learn XQuery × HTML HTML Tag Reference HTML Event Reference is not HTML Color Reference HTML Attribute Reference HTML Canvas Reference HTML SVG Reference Google Maps Reference CSS CSS Reference CSS Selector Reference W3.CSS Reference Bootstrap Reference Icon Reference JavaScript JavaScript Reference HTML DOM Reference jQuery Reference jQuery Mobile Reference AngularJS Reference XML XML Reference XML Http Reference XSLT Reference XML Schema Reference Charsets is not a HTML Character Sets HTML ASCII HTML ANSI HTML Windows-1252 HTML ISO-8859-1 HTML Symbols HTML UTF-8 Server Side PHP Reference SQL Reference ASP Reference × HTML/CSS HTML Examples CSS Examples W3.CSS Examples Bootstrap Examples JavaScript JavaScript Examples HTML DOM Examples jQuery Examples jQuery Mobile Examples AngularJS Examples AJAX Examples XML XML Examples XSLT Examples XPath Examples XML Schema Examples SVG Examples Server Side PHP Examples ASP Examples Quizzes HTML Quiz CSS Quiz JavaScript Quiz Bootstrap Quiz jQuery Quiz PHP Quiz SQL Quiz XML Quiz × JavaScript Reference Overview JavaScript JS String JS Number JS Operators JS Statements JS Math JS Date JS Array JS Boolean JS RegExp JS Global JS Conversion Browser BOM Window Navigator Screen History Location HTML DOM DOM Document DOM Elements DOM Attributes DOM Events DOM Style HTML Objects
May 2012 edited May 2012 in General I accept all suggestions, but this is mostly directed to allan, which I hope allan you can help me out. I've read about the errors surrounding this type detection\sorting plugin, for per instance 'currency' detection. You said in a thread (I've lost track) that it happens when DataTables it's trying to "work" on something that it's not a string. You also said that you've came across this a few times and you tried to fix it, well, what happens here is, I was implementing a custom currency type detection with success, then I have two fields that came from the DB (two integers), which I don't treat at all, so they are handled such as: "field" : 134, And I get -> sData.charAt is not a function If I for instance (in PHP) $field = "". $field; I get this in the aaData "field" : "134", And problem solved, but I have lots of tables I want to implement my custom currency, and I don't want to this "weird" trick to make my int's- string's, so DataTables doesn't trip out on me. Replies hozt Posts: 45Questions: 0Answers: 0 May 2012 The thing to notice here is, that the error column (the int) wasn't even the field i typed for the currency (with sType) neither it fit the expression matching for finding my " EUR" in the end of the string. allan Posts: 35,722Questions: 1Answers: 3,757 Site admin May 2012 DataTables core shouldn't have any problem with non-string data. It used to, in the dark old days, but that was long ago - possibly you found a forum thread from that time? Anyway - it should work fine now. If you do run across a case where it doesn't , please post a link to a test case so I can take a look at, and fix, the problem. Allan hozt Posts: 45Questions: 0Answers: 0 May 2012 Yes, once again I can only show it to you if I happen to give you a test password in PM, if you can. Since this project is now production, I just need a little bit of time, to set up a demo database. Also allan, I can't run debugger on the page, obviously, if I let the error happen. But want me to run it without the err