Skip to main content
Inspiring
February 12, 2010
Question

I need an action page to perform action but not display

  • February 12, 2010
  • 2 replies
  • 765 views

I have situation that requires an action to happen in an external URL without displaying a page. The page at the URL is not necessarily a ColdFusion template.

Specifically, I have an AddToCart URL; I would like to place an item in the shopping cart, but have no display of the page at that URL when the item is added to the cart. This way, a shopper can create a cart without having a page show up each time an item is added, then later go look at the completed cart.

Can this be accomplished with CF? If so, how?

I did some googling and looked through these forums but could not find anything – and I really have no idea what keywords to use for a search like this.

I would appreciate any ideas.

Regards to all,

Carlos

This topic has been closed for replies.

2 replies

Known Participant
February 15, 2010

<cfhttp method="Post" url="http://address.of.target.site/page-on-target-site?variable=value&variable_2=value_2&variable-3=value_3&etc=etc">

<cfhttpparam type="CGI"

   value="a"

   name="a"></cfhttp>

This should do what you are asking.

You can load all of the variables and values of those variables (order numbers, product id, price, etc) directly into the url= part of the cfhttp line.

You then create the cfhttpparam line exactly as I have it above.. because, for whatever reason, cfhttp likes to throw an error if there are no cfhttpparam's set - even if those parameters are meaningless.  The one I have above basically creates an a=a parameter, which (unless the target site actually uses 'a' as a variable name) should be meaningless, yet allow the cfhttp code to function.

I use code like this to automatically load xml sitemaps for pages to a variety of sites that use them to index for search engines and rss feeds.  It causes the 'insert' to work just fine, without ever showing anything on the users browser that it even happened at all.

If you need to verify that things are working correctly while you test this out,  simply add the following snippet of code after the cfhttpparam tag:

<cfoutput>
File Content:<br>
#cfhttp.filecontent#<br>
</cfoutput>

This will cause whatever results that normally would be displayed on the 'target web page' (if the information was being put into that page directly ON that target page instead of 'remotely') to show up on your page.   Once you're happy with the results, just delete the File Content snippet and you should be good to go.

WHeis

ilssac
Inspiring
February 12, 2010

There are several ways you could do something like this.

Whcih ones you choose would start with how you plan to get the data from the client to the server.

If you want to do basic form submits, then the action page has to do something to either display the resluts OR to redirect the client to a page that displays the results.  Even if the result is just the same page the user was already on.

If you wish to use AJAX to have JavaScript submit the data to the server, it could easily be done behind the scenes.

cheftimoAuthor
Inspiring
February 12, 2010

OK Ian, I think my original post needs a little clarification:

  • The cart is not on my site; I am not the merchant;
  • my site would send an item to be added to the shopping cart on the merchant's site;
  • the cart page would either not show up at all, or would get closed immediately without any action needed by the purchaser.

I can't think of any way this could be done without the cooperation of the merchant whose cart is being modified – but who knows?. Am I dreaming of something impossible here?

Carlos

Inspiring
February 12, 2010

You need some co-operation from the merchant.

From a programming perspective, you could have your user submit to a page that runs in a very small iframe.  That page can use cfhttp to talk to the merchant page.