javascript - Get individual values from Third Party Response Data in HTML page -
i need how individual values html page. got response payu payment gateway team in html page need individual attributes values tacking transaction
below response getting payu team:
<h1>this success url</h1> <p>your transaction completed successfully. bank response mihpayid=403993715514374636&mode=&status=failure&unmappedstatus=usercancelled&key=gtkffx&txnid=txn1r23fw&amount=100.00&discount=0.00&net_amount_debit=0.00&addedon=2016-04-25+10%3a48%3a29&productinfo=oxygenconcentrator&firstname=test&lastname=&address1=&address2=&city=&state=&country=&zipcode=&email=test%40gmail.com&phone=8152709721&udf1=&udf2=&udf3=&udf4=&udf5=&udf6=&udf7=&udf8=&udf9=&udf10=&hash=6a9d21bd423d61cd5a7d91098aa1140314e45eaddd8d4b9148399caba8ac61a9476aec130eb369f7d526e741b1b6c47b1ca71bec21fa69aa3deaa13740dbffbc&field1=&field2=&field3=&field4=&field5=&field6=&field7=&field8=&field9=cancelled+by+user&payment_source=payu&pg_type=&bank_ref_num=&bankcode=&error=&error_message= </p> <script> payu.onsuccess("mihpayid=403993715514374636&mode=&status=failure&unmappedstatus=usercancelled&key=gtkffx&txnid=txn1r23fw&amount=100.00&discount=0.00&net_amount_debit=0.00&addedon=2016-04-25+10%3a48%3a29&productinfo=oxygenconcentrator&firstname=test&lastname=&address1=&address2=&city=&state=&country=&zipcode=&email=test%40gmail.com&phone=8152709721&udf1=&udf2=&udf3=&udf4=&udf5=&udf6=&udf7=&udf8=&udf9=&udf10=&hash=6a9d21bd423d61cd5a7d91098aa1140314e45eaddd8d4b9148399caba8ac61a9476aec130eb369f7d526e741b1b6c47b1ca71bec21fa69aa3deaa13740dbffbc&field1=&field2=&field3=&field4=&field5=&field6=&field7=&field8=&field9=cancelled+by+user&payment_source=payu&pg_type=&bank_ref_num=&bankcode=&error=&error_message="); </script>
i got response below snippet
iabref.executescript( { code: "document.body.innerhtml" }, function( values ) { alert(values[0]); console.log(values[0]); } );
so need individual attribute values mihpayid ,mode,status , on......
assuming values or values[0] have : "mihpayid=403993715514374636&mode=&status=failure&unmappedstat"
then write function below:
function extractscript(source){ var pattern = /<script>(\w+)<\/script>/ var matches = source.match(pattern); return matches[1]; } function getvalue(source, key){ var pattern = key+'=(\\w+)(&)?'; var expr = new regexp(pattern); var result = source.match(expr); return result[1]; }
then in executescript:
iabref.executescript( { code: "document.body.innerhtml" }, function( values ) { //incase values[0] contains result string console.log(getvalue(values[0], 'mihpayid')) //or //incase values[0] contains result string console.log(getvalue(values, 'mihpayid')) } );
Comments
Post a Comment