Noob AJAX problem

  • I'm new to AJAX/PHP so it might be something simple. I'm retrieving a simple string from a webpage, which is just '1|2|3|4'. Four numbers seperated by the pipe symbol. It arrives fine but when I come to parse it, tokencount tells me that it sees 4 '|' symbols when clearly there are 3.

    To check it's not an error in my program, I typed in the string directly into a variable and it parse that instead. In that case, it gives the correct answer of 3, so I don't think it's anything to do with my commands.

    Is this something strange about AJAX/PHP or have I done something wrong?

  • tokencount tells you the number of "tokens". '1|2|3|4' has four tokens. '|' isn't a "token", its the numbers that are tokens.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Oh wow, I've been using 'tokenat' for years and always assuming the seperator was the token. Oddly, it doesn't matter if you get it wrong when using tokenat (if you assume tokenat 0 is the first seperator, you still get the first word anyway), but it does when you're using tokencount. Strangely, I was getting different results when using my AJAX.Lastdata string and an identical manual string, but it must've been because I was doing something slightly wrong.

    Anyway, it's working fine now, thanks for putting that straight

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)