-1

(Because a (Define) My php file shows a second line). It will have like OK+a empty line

So I would like to make my check so it's like not if responde = OK

but if response contains OK

Full code: http://meepbeta.tk/hotel/minified.js

The line I'm talking about:

var b=d.responseText;if(b=="OK"){saved=true;if(!a){var a="http://sunniedaynl.net/client"}showResult('<img src="dissi-editor.png" style="float: left;padding-left: 25px;"><strong>

Won't work:

Is there any way to make it like

if(b.Contains("OK")) //<--- This doesnt work

It doesn't work because of the second line

This is the script it checks:

function sendMap(){var a=getExport();asyncAjax("POST","check.php","gamemap="+a+"&doorx="+doorX+"&doory=‌​"+doorY,doChecks,{}

Then, it checks for the OK

b=d.responseText;if(b=="OK"){saved=true;if(!a){var a="sunniedaynl.net/client";}showResult('<img src="dissi-edit 

But I want it to check for something that contains OK not just check if the whole text is OK, so it'd even detect it if it was like OKay32r34.

Sam
  • 7,252
  • 16
  • 46
  • 65
  • Do you want to check for a line that _contains_ "OK" or a line that _starts_ with "OK"? Also, it's not clear: What do you want to do with a line that is like "OKay32r34"? – Ted Hopp May 20 '14 at 21:38
  • Hi there. I see you put a space in disallowed title phrases in order to escape the question quality filter. That's actually in there for a reason - please try to use question titles that are representative of the actual problem you are facing. – halfer Jun 07 '14 at 10:52

1 Answers1

0

I'd go with b.indexOf("OK") === 0. This ensures that the first two characters of b are "OK", matching "OKay32r34" but not matching "rOK".

I'd also like to note that b.Contains doesn't work because there's no method Contains defined, there is however contains but it checks for it anywhere in the string. (and thus would match "NOT OK")

Snuffleupagus
  • 6,365
  • 3
  • 26
  • 36
  • Well, id also like it to check even NOT OK, i just want it to detect if there's OK in that page somewhere EDIT i tink what u did is fine ima try it now THX :)! – user3641810 May 21 '14 at 17:15
  • EDIT: it doesnt work this is the file its checking in: [link](http://secretup.com/uploads/response.png?img=10)[/link] A part of my PHP script is causing that second line, but its not possible to remove it without it wont work, so i want it to detect the OK from there :/ anny ideas? – user3641810 May 21 '14 at 17:22
  • EDIT2: ive seem to insert it wrong somehow :P it didnt save it works like a charm thank you so much :D!!!!! – user3641810 May 21 '14 at 17:25
  • @user3641810: if this answer helped you, please accept it by clicking the tick mark to the left. It's how we thank people here. – halfer Jun 07 '14 at 10:48
  • @user3641810: please let me know here when you've accepted this (or why you aren't accepting) and I'll undownvote the question. Thanks. – halfer Jun 08 '14 at 23:38