ERROR TypeError: alert is not a function
at SafeSubscriber._error (home.ts:45)
at SafeSubscriber.__tryOrUnsub (Subscriber.js:238)
at SafeSubscriber.error (Subscriber.js:197)
at Subscriber._error (Subscriber.js:128)
at Subscriber.error (Subscriber.js:102)
at MapSubscriber._next (map.js:82)
at MapSubscriber.Subscriber.next (Subscriber.js:89)
at XMLHttpRequest.onLoad (http.js:1556)
at t.invokeTask (polyfills.js:3)
at Object.onInvokeTask (core.js:4620)

I’m receiving the otp but page is not redirecting to the otp receive page because of this error

And here, you’re using ‘alert’ as a function. I know your intention was probably the default js alert() function. But the compiler is thinking you’re talking about the above alert which is indeed not a function.

sagarkodte:

alert(“failed”);

Just change the variable name ‘alert’ to something else and you’ll be good.

If your “else” clause is not executed, then the page will not redirect to ‘OtpReceivePage’… And the way to see that is by this line below. If you see the data on your browser console, then the page should redirect. Can you see the ‘res’ you console logged?

No, I didn’t mean stick the line in the Console. I meant when you run your app and enter the 12 digit numbers and click “Ok” or “Submit”, do you get or see any data on the browser console after that or you get an alert with “failed”?

SyntaxError: Unexpected token < in JSON at position 0
at JSON.parse (<anonymous>)
at Response.Body.json (http.js:1063)
at MapSubscriber.project (home.ts:39)
at MapSubscriber._next (map.js:79)
at MapSubscriber.Subscriber.next (Subscriber.js:89)
at XMLHttpRequest.onLoad (http.js:1556)
at t.invokeTask (polyfills.js:3)
at Object.onInvokeTask (core.js:4620)
at t.invokeTask (polyfills.js:3)
at r.runTask (polyfills.js:3)

Looks like your ‘send-sms.php’ isn’t returning the correct data format (JSON). And it needs to return JSON for this to work. Whatever your file is returning begins with ‘<’ and it could be XML or HTML.

Sorry dude, I’ve never used PHP in my life. But if you wanna see your Response (returned data). Run your app, before entering the 12 numbers and firing the request (Send)

Click F12 to go to browser dev tools, click the Network tab.
Enter the 12 digit number on your form and submit… On your Network click on the last request’s name, its gonna open another window, then click on ‘Reponse’ and you should be able to see where you went wrong… Example below