I have a site.master page in which I need to collect a newsletter signup, so I would prefer if I can provide feedback immediately to the user as they signup, and not disrupt any other page activities. It is a simple textbox and button.
The data then gets written to a remote WCF web service, so could I use an AJAX call, although that would be cross domain, which might be an issue. The service returns a message of success or why failed.
So, my questions are, what would be the best approach for this implementation, and can I use the service?
Thanks! Brad
In order to avoid the cross-domain problem, I would use the "double hop" solution. First, add a reference to the WCF service in your project. Then create a method in your Controller that returns a JsonResult
, and inside that method you can call the WCF service and return the result as JSON.
Then in the client app you can use a standard .ajax()
method to do the sign-up. It's a little convoluted with the number of hops, but it lets you control each step of the process and avoids the cross-domain problem.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.