The essence is this: there is an ajax function that sends 5 different headers (respectively, the headers: "st", "so", "ga", "vi", "mo"), depending on the user's actions, to the server and receive a response in the form of an object . object is returned When sending 4 out of 5 headers, everything works correctly and the object is returned, but when sending the fifth ("ga"), the object and third-party code are returned to me in the form of an ad unit TOGETHER with this object. object AND third-party code I’m sure that in the database I don’t have such a code that comes to me with a response from the server, and therefore the server couldn’t put it there. The code somehow gets woven by itself. How to eliminate it or how can I separate the object from this foreign code in js?

Closed due to the fact that off-topic participants are Alexey Shimansky , dirkgntly , Grundy , sercxjo , Ivan Pshenitsyn 23 Aug '16 at 14:22 .

It seems that this question does not correspond to the subject of the site. Those who voted to close it indicated the following reason:

  • “Questions asking for help with debugging (“ why does this code not work? ”) Should include the desired behavior, a specific problem or error, and a minimum code for playing it right in the question . Questions without an explicit description of the problem are useless for other visitors. See How to create minimal, self-sufficient and reproducible example . " - Alexey Shimansky, dirkgntly, Grundy, sercxjo, Ivan Pshenitsyn
If the question can be reformulated according to the rules set out in the certificate , edit it .

  • Do not force us to break eyes with your screenshots, give a piece of the program and the server answers in question in text form. - sercxjo
  • @sercxjo in response comes a huge object, with Cyrillic encoded, I do not think it's interesting to watch. The code is also huge, and I’m giving a tooth, there’s no this ad unit there. This block is somehow interlaced in a third-party way, perhaps the reason is hosting, since on my local server everything works correctly for me. - Diskyp
  • @Diskyp Well, if you do not want to show anything, what kind of help do you expect? Psychics are on the channel TNT. .... And in general, according to the information provided, you can also say: you have something wrong, I give a tooth. - Alexey Shimansky
  • @ Alexey Shimansky is good, for especially witty people I will explain it briefly and clearly: THE PROBLEM IS NOT IN THE CODE. If you so want to look at my gorgeous php code, then write the mail, I personally throw off. - Diskyp
  • one
    @Diskyp, why don't you ask this question from the hoster itself? If the problem is not in the code, then it is in the periphery of the server, to which neither we nor you, as I understand it, has access. Well, in an extreme case, before answering, make server-side logs and check them. - Alex Krass

1 answer 1

In short, I solved my problem. The response that came with a third-party code was naturally dropped into error and there I did such a simple parsing:

error: function(xhr, status, error) { str=xhr.responseText.replace(/<div(\s|.)+<\/div>/,''); str=JSON.parse(str); }, 

Thanks to him, the foreign code was deleted from the answer, and the string was converted to an object. This is actually what I asked for help.