14

I was trying to post an answer to this question, while the system started to bombard me with error messages saying Body cannot contain <starting few words of the answer>, whatever I tried the same error started coming

Sample 1

Sample 2

In sample 2, I tried with a text that was already accepted in the previous answer, even that was not allowed.

Sample 3

Is this a new validation that was added to the system?


The complete answer that I wanted to post is something like

The problem is .map() will flatten the array returned from the callback method. A solution to this is to wrap the array with another one as given below

You can also read the text of the firstChild of the li element to get the first part of the inner array as given below

function getData() {
  var sourceData = $("#source").find("li");
  return sourceData.map(function(i, item) {
    return [
      [$(item.firstChild).text().trim().slice(0, -1), $(item).find("b").text()]
    ];
  }).get();
}

var data = getData();
$('pre').text(JSON.stringify(data))
console.log(data)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<ul id="source">
  <li>北京空气质量:<b>90</b>
  </li>
  <li>上海空气质量:<b>70</b>
  </li>
  <li>天津空气质量:<b>80</b>
  </li>
  <li>广州空气质量:<b>50</b>
  </li>
  <li>深圳空气质量:<b>40</b>
  </li>
  <li>福州空气质量:<b>32</b>
  </li>
  <li>成都空气质量:<b>90</b>
  </li>
</ul>

<pre></pre>

5
  • I guess it just gets caught on one special word or so. But it's weird that even if you write something different it can't contain the start from your answer.
    – Rizier123
    Commented Apr 13, 2016 at 4:14
  • 1
    I tried a lot of stuff, like The problem is .map() will flatten, jQuery .map() will flatten etc and of course is there anything that will allow me to post it :( Commented Apr 13, 2016 at 4:17
  • 3
    I think it would be safe to add the bug tag to this one...
    – Anders
    Commented Apr 13, 2016 at 12:28
  • 2
    Because your trying to put in content like: 成都空气质.. it thinks it's spam, or something. Why it doesn't for the question? Who knows.
    – TZHX
    Commented Apr 13, 2016 at 12:38
  • Well, that's interesting.
    – cat
    Commented Apr 13, 2016 at 13:06

0

Browse other questions tagged .