php - Unable to send POST request using AJAX -
I am unable to send a post request to my php file using AJAX. I have two files, the first is an index.php and the second is VerificationStatusAPIV2.php. The topics of index.php are:
& lt; Html & gt; & Lt; Top & gt; & Lt; Meta http-equiv = "content-type" content = "text / html; charset = UTF-8" & gt; Dial 2 Verified API V2 (www.dial2verify.com) & lt; / Title & gt; By & lt; Title & gt; Phone Verification & Lt; Script type = "text / javascript" src = "http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" & gt; & Lt; / Script & gt; & Lt; Script type = "text / javascript" & gt; Var try = 1; Var transactionTokan = ""; $ (Document) .ready (function () {$ ("# enter_number"). Submit (function (e) {e.preventDefault (); Start dial2Verify ();});}); Launch FunctionDial2 Verify () {showCodeForm (1); GetVerificationImage (); } ShowcodeForm (code) {$ ("# dial2verify"). FadeIn (); $ ("# Enter_number") fadeOut () .; $ ("# Waiting_msg"). Text ("" waiting for missed call "+ $ (" # phone_number "). Val ());} function (data) {updateImage (data.img, data.transactionToken);}, ()," json " "); } Function Update Image (IMG, VATENESSAction Token) {$ ("#Image"). Html ("Please Miss Miss" call & lt; br & gt; & lt; img src = \ "" + img + "\" / "/>"); TransactionToken = vtransactionToken; PollStart ("0");} Function Checkstats () {$ .post ("VerificationStatusAPIV2.php", {transactionToken: transactionToken}, function (data) {PollStart (data.status);}, "json");} function (vStatus) {attempt = effort + 1 ; If (attempt> = 90) {timeout check ();} and if (vStatus === "0") {$ ("# condition"). Html ("Please Missed Call & lt; b & gt; ; & Lt; i & gt; "+ + (90-try) +" & lt; / I & gt; & lt; / b & gt; Seconds); SetTimeout (CheckStatus, 1000);} and if ( VStatus === "1") {success ();} and timeout check ();} function error () {$ ("# Condition"). Html ("Error! <> & Lt; Sorry something went wrong, please check your telephone number. '); } Function success () {$ ("# condition"). Text ("Congratulations !!! Phone Number Verified!"); } Function timeout check () {$ ("# condition"). Text ("Verification Failed!"); } & Lt; / Script & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt; Form id = "enter_number" & gt; & Lt; P & gt; Enter your phone number: & lt; / P & gt; & Lt; P & gt; & Lt; Input type = "text" name = "phone_number" id = "phone_number" /> & Lt; / P & gt; & Lt; P & gt; & Lt; Input type = "submit" name = "submit" value = "verify" /> gt; & Lt; / P & gt; & Lt; / Form & gt; & Lt; Div id = "dial2verify" style = "display: none;" & Gt; & Lt; P id = "waiting_msg" & gt; & Lt; / P & gt; & Lt; P id = "image" & gt; Loading .. & lt; / Strong> & Lt; / P & gt; & Lt; P id = "status" & gt; Loading .. & lt; / Strong> & Lt; / P & gt; & Lt; / Div & gt; & Lt; / Body & gt; & Lt; / Html & gt; In the Checkstats () function I am sending a post request after using AJAX for verification, but it is not requesting any posts. Can anyone say that what is wrong with that?
Update I have noticed that fancy checkstat (yellow) in "data.states" in "status" is yellow while others have blue color. Probably what is this problem?
You have only one place in your code that you have CheckStatus This line is outgoing for the function ... setTimeout (CheckStatus, 1000); So if this function is called, then it should be like this: setTimeout (CheckStatus (), 1000);
This may be your problem.
Comments
Post a Comment