/    Sign up×
Community /Pin to ProfileBookmark

Get info from the "str"

Hello.

I have this function and I need to know what there is in the “str”
————-

function sendPut(str, content) {
var xhr = new XMLHttpRequest();
xhr.open(“PUT”, “http://” + ipPort + “/” + str);
xhr.send(content);

}
——–

I haver tried
document.writeln( str );
and
document.getElementById
in different ways but not got any “str” data on my website.

Anybody know ??

MagI

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@JMRKERFeb 21.2013 — Although I don't think your function will work, you can see the value of 'str' (if it is displayable) with an 'alert()' function
<i>
</i>function sendPut(str, content) { [COLOR="#FF0000"]alert('Contents of "str": '+str);[/COLOR]
var xhr = new XMLHttpRequest();
xhr.open("PUT", "http://" + ipPort + "/" + str);
xhr.send(content);
}


BTW, you should enclose your code between [ code] and [ /code] tags (without the spaces)

to make it easier to see your question. It also retains formatting of indentation, if any.
Copy linkTweet thisAlerts:
@jlivingstonsgauthorFeb 21.2013 — --

Hi.

The sendPut function work.

It is a working android code by google and it is called "Cellbots"

http://www.cellbots.com/

http://goo.gl/qKs4p

Here is the code

http://code.google.com/p/cellbots/source/browse/#svn%2Ftrunk%2Fandroid%2Fjava%2Fcellbots

And here is the index.html code with my function.

http://code.google.com/p/cellbots/source/browse/trunk/android/java/cellbots/assets/index.html


The code "alert('Contents of "str": '+str);" worked almost.

It alert "command.php" from the "sendAction" function.

The command.php have this wiki.

http://code.google.com/p/cellbots/source/browse/wiki/LegoNXTDocumentation.wiki

But I need to know what is in the "str"

It is supposed to be a mailbox message using message wrapping and have this kind of structure
----------------


  • * Byte 0: 0x80 (direct command with no response from the NXT)

  • * Byte 1: 0x09 (message command type)

  • * Byte 2: 0x01 (Mailbox number, 0-9)

  • * Byte 3: Message Size (including null terminating character)

  • * Byte 4-N: Message data, where N = Message size + 3 and ends with a null terminating character

    -----------------


  • http://goo.gl/PiqRI

    You can read about the message wrapping in PDF Appendix 3 / page 9.

    Thanks for your input but this is a hard one.

    Is it possible to get the data out of the command.php ?

    Regards Magnus
    --

    Copy linkTweet thisAlerts:
    @JMRKERFeb 21.2013 — This must be something special on the site as normal JS would need a server to put the information to.

    I'm assuming google is providing this space for you.

    Have you alerted the 'content', similar to the command for the 'str'.

    It may have special code that make it unreadable with ASCII characters.
    Copy linkTweet thisAlerts:
    @jlivingstonsgauthorFeb 21.2013 — --

    The "cellbots" app make the phone work as a network camera server so the index.html / sendPut send the command to the phone

    and then it is transferred to the lego mindstorm nxt robot by bluetooth.


    I tried to change "str" to "content"

    <i>
    </i>function sendPut(str, content) {
    alert('Contents of "content": '+content);
    var xhr = new XMLHttpRequest();
    xhr.open("PUT", "http://" + ipPort + "/" + str);
    xhr.send(content);
    }


    And the alert wrote the key commands f/b/l/r and so on.

    So the "str" that give the "command.php" is the best candidate.

    There should be some way to get the info from the command.php.

    Any suggestion anytime is gladly received.



    Regards MagI

    --
    Copy linkTweet thisAlerts:
    @jlivingstonsgauthorFeb 21.2013 — --

    So I guess it activates the phone server to receive a command by the

    http://" + ipPort + "/" + command.php

    and then send the content = "f" or "b" or "l" or "r"

    and it is in the phone the content is made to a mailbox message using message wrapping and have this kind of structure
    ----------------


  • * Byte 0: 0x80 (direct command with no response from the NXT)

  • * Byte 1: 0x09 (message command type)

  • * Byte 2: 0x01 (Mailbox number, 0-9)

  • * Byte 3: Message Size (including null terminating character)

  • * Byte 4-N: Message data, where N = Message size + 3 and ends with a null terminating character

    -----------------


  • I have tried to find the command.php file in the cellbots files but have had no luck.

    Maybe the command.php is in the android files?

    What do you think?

    Regards MagI

    --
    ×

    Success!

    Help @jlivingstonsg spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 5.18,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @AriseFacilitySolutions09,
    tipped: article
    amount: 1000 SATS,

    tipper: @Yussuf4331,
    tipped: article
    amount: 1000 SATS,

    tipper: @darkwebsites540,
    tipped: article
    amount: 10 SATS,
    )...