why not split() string returned by Ajax method() in JavaScript
-
[AjaxPro.AjaxMethod] public string Ajax_Getstr() { return "39.01235,118.0456782"; } There are functions in Javascript as follow: function Getstr() { var str0 ="21332,678"; var arr0 = new Array(); arr0 = str0.split(","); alert(arr0[0]);//here display is "21332",very good var str1 = _Default.Ajax_Getstr(); alert(str1.value);//so far, all is well var arr1 = new Array(); arr1 = str1.split(",");//display error alert(arr1[0])//here diaplay undefined }
-
[AjaxPro.AjaxMethod] public string Ajax_Getstr() { return "39.01235,118.0456782"; } There are functions in Javascript as follow: function Getstr() { var str0 ="21332,678"; var arr0 = new Array(); arr0 = str0.split(","); alert(arr0[0]);//here display is "21332",very good var str1 = _Default.Ajax_Getstr(); alert(str1.value);//so far, all is well var arr1 = new Array(); arr1 = str1.split(",");//display error alert(arr1[0])//here diaplay undefined }
I didnt understand lots of thing here but your problem and solution is in
arr1 = str1.split(",");//this is not correct
arr1 = str1.value.split(",");//this is correct
-
[AjaxPro.AjaxMethod] public string Ajax_Getstr() { return "39.01235,118.0456782"; } There are functions in Javascript as follow: function Getstr() { var str0 ="21332,678"; var arr0 = new Array(); arr0 = str0.split(","); alert(arr0[0]);//here display is "21332",very good var str1 = _Default.Ajax_Getstr(); alert(str1.value);//so far, all is well var arr1 = new Array(); arr1 = str1.split(",");//display error alert(arr1[0])//here diaplay undefined }
as johny10151981 suggested
var str1 = _Default.Ajax_Getstr();
alert(str1.value);
var arr1 = new Array();
arr1 = str1**.value**.split(",");//str1.split(",");
alert(arr1[0]);