Re: Replace cfhttp with jquery.post()
That's a great idea, and I have everything working to do that now. I get the query back, serializeJSON the results and I can see them in an alert box. BUT. For the life of me I cannot figure out how to access those elements with jQuery. This should probably be in a new thread, and I do see alot of threads where people are frustrated with this. I have been pulling my hair out for hours. jsonvar = serializeJSON(qry) tostring(jsonvar, 'jsvar') I really just want to do jsvar.field1 or jsvar.field2. That doesn't work. I have tried variations of $.each and everything I can find out there. No luck. How can I get to those values with jquery? --- David Mineer Jr - The critical ingredient is getting off your butt and doing something. It's as simple as that. A lot of people have ideas, but there are few who decide to do something about them now. Not tomorrow. Not next week. But today. The true entrepreneur is a doer. On Fri, May 6, 2011 at 9:54 PM, andy matthews li...@commadelimited.comwrote: Simplest thing to do would be to put the cfhttp call into a cfc, then call that from jQuery. andy -Original Message- From: David Mineer Jr [mailto:min...@gmail.com] Sent: Friday, May 06, 2011 7:53 PM To: cf-talk Subject: Re: Replace cfhttp with jquery.post() K, hold up. This has something to do with the ip address of the calling function. This program can only be called from the local server i.e. localhost. cfhttp must call from localhost and so it works. jQuery.post() must call from the client ip address and therefore won't ever work. So I better look more into this and see how I am going to handle this. This is an internal app and that service only responds to internal requests. --- David Mineer Jr - The critical ingredient is getting off your butt and doing something. It's as simple as that. A lot of people have ideas, but there are few who decide to do something about them now. Not tomorrow. Not next week. But today. The true entrepreneur is a doer. On Fri, May 6, 2011 at 5:55 PM, David Mineer Jr min...@gmail.com wrote: Nice catch. I also had address2 instead of addressline2. I changed those and still nothing. I get the code pasted above for the post info when I click on the link, but the response info is blank. That's what has me flustered. I get nothing back. The link turns red and I can alert that there was an error, just don't know how to return the error that is sent back (assuming it is getting back to me. ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:344326 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
RE: Replace cfhttp with jquery.post()
Are you sending it back to the browser as Json? I would be more inclined to do that, and remove the serialise json from the JavaScript. Then you will be able to do what you are wanting to do. Regards, Andrew Scott http://www.andyscott.id.au/ ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:344328 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: Replace cfhttp with jquery.post()
It sounds like you're mixing up server side and client side (spank me if I'm wrong). Your server side will be taking some request and spitting out plain text json. It doesn't know, or need to know, of jquery. An example plain cfm: !--- some.cfm --- cfset myData = getMyData() /!--- some logic --- cfsetting enablecfoutputonly=true showdebugoutput=false / cfcontent reset=true type=application/json / cfoutput#serializeJson( myData )#/cfoutputcfabort / An ajax request from the client could call the 'some.cfm' page and when the response comes back the client can interpret that json response. So in jQuery: $(document).ready(function(){ var url = 'some.cfm', // relative mydata = {address1 : '68 N 4000 W', address2 : '' ,city : 'Cedar City', state : 'UT'}; $.post(url, mydata, function(resp){ console.dir( resp ); // if you're using firebug or the Chrome console, check the console tab for output. console.dir is like a js version of cfdump }, 'json'); // this tells jquery that it is expecting a json string back - your resp variable should now be a parsed object of your json response }); HTH Dominic On 7 May 2011 07:53, David Mineer Jr min...@gmail.com wrote: That's a great idea, and I have everything working to do that now. I get the query back, serializeJSON the results and I can see them in an alert box. BUT. For the life of me I cannot figure out how to access those elements with jQuery. This should probably be in a new thread, and I do see alot of threads where people are frustrated with this. I have been pulling my hair out for hours. jsonvar = serializeJSON(qry) tostring(jsonvar, 'jsvar') I really just want to do jsvar.field1 or jsvar.field2. That doesn't work. I have tried variations of $.each and everything I can find out there. No luck. How can I get to those values with jquery? --- David Mineer Jr - The critical ingredient is getting off your butt and doing something. It's as simple as that. A lot of people have ideas, but there are few who decide to do something about them now. Not tomorrow. Not next week. But today. The true entrepreneur is a doer. On Fri, May 6, 2011 at 9:54 PM, andy matthews li...@commadelimited.comwrote: Simplest thing to do would be to put the cfhttp call into a cfc, then call that from jQuery. andy -Original Message- From: David Mineer Jr [mailto:min...@gmail.com] Sent: Friday, May 06, 2011 7:53 PM To: cf-talk Subject: Re: Replace cfhttp with jquery.post() K, hold up. This has something to do with the ip address of the calling function. This program can only be called from the local server i.e. localhost. cfhttp must call from localhost and so it works. jQuery.post() must call from the client ip address and therefore won't ever work. So I better look more into this and see how I am going to handle this. This is an internal app and that service only responds to internal requests. --- David Mineer Jr - The critical ingredient is getting off your butt and doing something. It's as simple as that. A lot of people have ideas, but there are few who decide to do something about them now. Not tomorrow. Not next week. But today. The true entrepreneur is a doer. On Fri, May 6, 2011 at 5:55 PM, David Mineer Jr min...@gmail.com wrote: Nice catch. I also had address2 instead of addressline2. I changed those and still nothing. I get the code pasted above for the post info when I click on the link, but the response info is blank. That's what has me flustered. I get nothing back. The link turns red and I can alert that there was an error, just don't know how to return the error that is sent back (assuming it is getting back to me. ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:344336 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: Replace cfhttp with jquery.post()
Not sure if it's just and oversight, but you've got address in the CFHTTP version and address1 in the jQ version. As for the error, don't you get the response struct in Firebug if you click on the URL? On 5/6/2011 6:11 PM, David Mineer Jr wrote: I am trying to replace this: CFhttp URL=http://localhost:8082/; method=post cfhttpparam name=address value=68 N 4000 W type=formfield cfhttpparam name=addressline2 value= type=formfield cfhttpparam name=city value=Cedar City type=formfield cfhttpparam name=state value=UT type=formfield /CFHTTP with this $(document).ready(function(){ var url = 'http://localhost:8082/', mydata = {address1 : '68 N 4000 W', address2 : '' ,city : 'Cedar City', state : 'UT'}; $.post(url, mydata,function(resp){ alert(resp); } ); }); the jQuery seems to work, but I get nothing back and the post url turns red in firebug. How do I at least return an error. I can return that there is an error, but not the actual error message. The cfhttp works great and returns xml. If I could figure out the actual error message I could maybe move to the next step. Firebug returns the following in the post tab: POST http://localhost:8082/ HeadersPostResponse Parametersapplication/x-www-form-urlencoded address168 N 4000 Waddress2 cityCedar CitystateUT Source address1=68+N+4000+Waddress2=city=Cedar+Citystate=UT but nothing in the response tab --- David Mineer Jr - The critical ingredient is getting off your butt and doing something. It's as simple as that. A lot of people have ideas, but there are few who decide to do something about them now. Not tomorrow. Not next week. But today. The true entrepreneur is a doer. ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:344310 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: Replace cfhttp with jquery.post()
Nice catch. I also had address2 instead of addressline2. I changed those and still nothing. I get the code pasted above for the post info when I click on the link, but the response info is blank. That's what has me flustered. I get nothing back. The link turns red and I can alert that there was an error, just don't know how to return the error that is sent back (assuming it is getting back to me. --- David Mineer Jr - The critical ingredient is getting off your butt and doing something. It's as simple as that. A lot of people have ideas, but there are few who decide to do something about them now. Not tomorrow. Not next week. But today. The true entrepreneur is a doer. On Fri, May 6, 2011 at 5:02 PM, Jason Fisher ja...@wanax.com wrote: Not sure if it's just and oversight, but you've got address in the CFHTTP version and address1 in the jQ version. As for the error, don't you get the response struct in Firebug if you click on the URL? On 5/6/2011 6:11 PM, David Mineer Jr wrote: I am trying to replace this: CFhttp URL=http://localhost:8082/; method=post cfhttpparam name=address value=68 N 4000 W type=formfield cfhttpparam name=addressline2 value= type=formfield cfhttpparam name=city value=Cedar City type=formfield cfhttpparam name=state value=UT type=formfield /CFHTTP with this $(document).ready(function(){ var url = 'http://localhost:8082/', mydata = {address1 : '68 N 4000 W', address2 : '' ,city : 'Cedar City', state : 'UT'}; $.post(url, mydata,function(resp){ alert(resp); } ); }); the jQuery seems to work, but I get nothing back and the post url turns red in firebug. How do I at least return an error. I can return that there is an error, but not the actual error message. The cfhttp works great and returns xml. If I could figure out the actual error message I could maybe move to the next step. Firebug returns the following in the post tab: POST http://localhost:8082/ HeadersPostResponse Parametersapplication/x-www-form-urlencoded address168 N 4000 Waddress2 cityCedar CitystateUT Source address1=68+N+4000+Waddress2=city=Cedar+Citystate=UT but nothing in the response tab --- David Mineer Jr - The critical ingredient is getting off your butt and doing something. It's as simple as that. A lot of people have ideas, but there are few who decide to do something about them now. Not tomorrow. Not next week. But today. The true entrepreneur is a doer. ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:344312 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: Replace cfhttp with jquery.post()
K, hold up. This has something to do with the ip address of the calling function. This program can only be called from the local server i.e. localhost. cfhttp must call from localhost and so it works. jQuery.post() must call from the client ip address and therefore won't ever work. So I better look more into this and see how I am going to handle this. This is an internal app and that service only responds to internal requests. --- David Mineer Jr - The critical ingredient is getting off your butt and doing something. It's as simple as that. A lot of people have ideas, but there are few who decide to do something about them now. Not tomorrow. Not next week. But today. The true entrepreneur is a doer. On Fri, May 6, 2011 at 5:55 PM, David Mineer Jr min...@gmail.com wrote: Nice catch. I also had address2 instead of addressline2. I changed those and still nothing. I get the code pasted above for the post info when I click on the link, but the response info is blank. That's what has me flustered. I get nothing back. The link turns red and I can alert that there was an error, just don't know how to return the error that is sent back (assuming it is getting back to me. ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:344313 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: Replace cfhttp with jquery.post()
This program can only be called from the local server i.e. localhost. cfhttp must call from localhost and so it works. You could easily write a little CF-based form post proxy that would take in the request and re-post it internally and pass the results back to the client. -Justi ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:344314 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: Replace cfhttp with jquery.post()
If the page you are trying to call is not web accessible then that indeed would be your problem, can;t you just put in the same folder as the rest of the site so that you can call it from Jquery ? On Sat, May 7, 2011 at 1:59 AM, Justin Scott leviat...@darktech.org wrote: This program can only be called from the local server i.e. localhost. cfhttp must call from localhost and so it works. You could easily write a little CF-based form post proxy that would take in the request and re-post it internally and pass the results back to the client. -Justi ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:344315 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: Replace cfhttp with jquery.post()
The cfhttp portion works from the same page. And for the program it uses You have to define the ip addresses that it listens on, so of course your options are limited there. It is only for an internal app, but building it like everything else using CF is what works best for me. --- David Mineer Jr - The critical ingredient is getting off your butt and doing something. It's as simple as that. A lot of people have ideas, but there are few who decide to do something about them now. Not tomorrow. Not next week. But today. The true entrepreneur is a doer. On Fri, May 6, 2011 at 7:18 PM, Russ Michaels r...@michaels.me.uk wrote: If the page you are trying to call is not web accessible then that indeed would be your problem, can;t you just put in the same folder as the rest of the site so that you can call it from Jquery ? On Sat, May 7, 2011 at 1:59 AM, Justin Scott leviat...@darktech.org wrote: This program can only be called from the local server i.e. localhost. cfhttp must call from localhost and so it works. You could easily write a little CF-based form post proxy that would take in the request and re-post it internally and pass the results back to the client. -Justi ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:344316 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
RE: Replace cfhttp with jquery.post()
Simplest thing to do would be to put the cfhttp call into a cfc, then call that from jQuery. andy -Original Message- From: David Mineer Jr [mailto:min...@gmail.com] Sent: Friday, May 06, 2011 7:53 PM To: cf-talk Subject: Re: Replace cfhttp with jquery.post() K, hold up. This has something to do with the ip address of the calling function. This program can only be called from the local server i.e. localhost. cfhttp must call from localhost and so it works. jQuery.post() must call from the client ip address and therefore won't ever work. So I better look more into this and see how I am going to handle this. This is an internal app and that service only responds to internal requests. --- David Mineer Jr - The critical ingredient is getting off your butt and doing something. It's as simple as that. A lot of people have ideas, but there are few who decide to do something about them now. Not tomorrow. Not next week. But today. The true entrepreneur is a doer. On Fri, May 6, 2011 at 5:55 PM, David Mineer Jr min...@gmail.com wrote: Nice catch. I also had address2 instead of addressline2. I changed those and still nothing. I get the code pasted above for the post info when I click on the link, but the response info is blank. That's what has me flustered. I get nothing back. The link turns red and I can alert that there was an error, just don't know how to return the error that is sent back (assuming it is getting back to me. ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:344322 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm