For registering the code in xDB using jQuery AJAX with Sitecore MVC, I referred following articles:
After writing code as mentioned in the articles, I open the page in Experience editor and tried to register the goal through AJAX.
BUT, it failed!!!
The reason is, I get an empty item under Tracker.Current.Session.Interaction.PreviousPage.
Then I have to spin my own wheels of thoughts to find the reason why the item is empty. I started looking for other blogs to find if anyone has same issue, but not where I found it. I spent two days in thinking that why that item with PreviousPage is empty and suddenly I got a spark that, goals are triggered from published website and I was testing it from Experience Editor which is taking /application/content editor as the item and that’s the reason!!!!
So, I published my site, hit the button for AJAX request and IT WORKED….