Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. why not split() string returned by Ajax method() in JavaScript

why not split() string returned by Ajax method() in JavaScript

Scheduled Pinned Locked Moved Web Development
javascriptdata-structureshelp
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    barackzhu
    wrote on last edited by
    #1

    [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 }

    M D 2 Replies Last reply
    0
    • B barackzhu

      [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 }

      M Offline
      M Offline
      Mohibur Rashid
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0
      • B barackzhu

        [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 }

        D Offline
        D Offline
        denny philip
        wrote on last edited by
        #3

        as johny10151981 suggested

        var str1 = _Default.Ajax_Getstr();
        alert(str1.value);
        var arr1 = new Array();
        arr1 = str1**.value**.split(",");//str1.split(",");
        alert(arr1[0]);

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups