Request is made

$.ajax({url: href+'?_top_ .p'}).done(function(data) {alert(data)}); 

As a result, the result is output in two lines (an entry about the server loading speed <!-- 0.22611 --> , which cannot be removed)

How to pull out the first line from data ?

  • Take the substring from the zero index to the first occurrence of \n .... Or you can delete everything from the position <!-- - Alexey Shimansky
  • same answer from server - splash58

2 answers 2

Found the answer

 data.split('\n')[1] 

All responded, thanks

    You can try this:

     alert(data.substring(0,data.indexOf("\n"))); 

    Here is a working code example:

     <button onclick="myFunction('Hello \n world!');"> Push me </button> <script> function myFunction(data) { alert(data.substring(0,data.indexOf("\n"))); } </script> 

    • For some reason it does not work in this form, it works in this form data.split ('\ n') [1] - Victor Onhodoev