search

Home  >  Q&A  >  body text

javascript - How to convert the text in Object Text into a string? Waiting online, urgent!

I got an Object Text from the background here, and now I need to convert it to String for output. Could you please tell me how I can convert it? I tried many methods on the Internet but it didn't work. . .

It looks like this when the content alert pops up

Let it output on the console like this

I want to turn it into a string because there are subsequent operations. Is there any way?

为情所困为情所困2715 days ago973

reply all(4)I'll reply

  • phpcn_u1582

    phpcn_u15822017-06-26 10:53:34

    You can get the object content through console.dir(a);, so you can see that there is a data attribute, and you can get the string by getting the .data attribute.

    reply
    0
  • typecho

    typecho2017-06-26 10:53:34

    JSON.stringify() Try if it works
    stringify() is used to parse a string from an object, such as

    var
    a = {a:1,b:2}

    Result:

    JSON.stringify(a)

    "{"a":1,"b":2}"

    reply
    0
  • 阿神

    阿神2017-06-26 10:53:34

    Try .data or .wholeText

    alert(a.data);
    Result of

    alert(a):

    The result of

    alert(a.data):

    Result of

    alert(a.wholeText):

    reply
    0
  • 女神的闺蜜爱上我

    女神的闺蜜爱上我2017-06-26 10:53:34

    How is the data? Post a picture. I don’t know what’s going on!

    reply
    0
  • Cancelreply