You are using web3.eth.getTransaction(txHash)
web3.eth.getTransaction(txHash) will only return info like like blockHash, transactionIndex, from, to, etc.
You have to register the event using web3js.
This is the code I used:
Solidity code:
pragma solidity ^0.4.17;
//Contract for storing ticket info
contract TicketRes {
event on_success_booking(address userId, string bookingId, string emailId);
//Ticket info having two storage values i.e email and userID
struct BookingInfo{
string emailId;
address userId;
}
//Map for saving all the info, assuming all ticket has unique id as key. Value is ticket info
mapping(bookingId=>BookingInfo) internal info;
function Book() public {
}
//Method will save all basic info, and will raise event.
function onBookingCompleted(address id, string bookingId, string emailId) public {
info[bookingId] = BookingInfo(emailId,userId);
on_success_booking(id, bookingId, emailId);
}
//You can get info by using bookingid at any point of time.
function getBookingInfo(string bookingId) public constant returns(string, address){
return (info[bookingId].emailId, info[bookingId].userId);
}
}
Now Javascript code:
// Contract deployed address.
var contractAddress = "0x06433f4fc50423f71329597f50fb0a42cfecb11f";
if (typeof web3 !== 'undefined') {
web3 = new Web3(web3.currentProvider);
} else {
// set the provider you want from Web3.providers
web3 = new Web3(new Web3.providers.HttpProvider("http://127.0.0.1:8545"));
}
//Open build folder and you will find contact json file copy the appropriate JSON and paste it there.
var contractABI = web3.eth.contract(/** ABI Here **/);
//Connected contract to your local network
var contract = contractABI.at(contractAddress);
//Loading booking event function.
var booking_event = web3.sha3('on_success_booking(address,string,string)');
//Watching events, when onBookingCompleted() tran's mined then event get triggered. You can get all previous events also. for that need to apply filters.
booking_event.watch((error, result) => {
if(error){
console.log("error",error);
}
console.log("Result", result); //result.args holds values, result.args.id, result.args.bookingId and result.args.emailid
});