House of Fusion
Search over 2,500 ColdFusion resources here
  
Home of the ColdFusion Community

Mailing Lists
Home /  Groups /  JQuery

escaping special charaters in jQuery form field

  << Previous Post |  RSS |  Sort Oldest First |  Sort Latest First |  Subscribe to this Group Next >> 
Nope, I'm not seeing it in that pastebin.
Raymond Camden
01/18/11 12:15 P
Hi, Teed...
Rick Faircloth
01/19/11 09:41 A
Check the docs for ajax() method:
Raymond Camden
01/19/11 10:16 A
Rick and Teed,
Rob Parkhill
01/19/11 11:21 A
Rob explained it - sorry was on the phone.
Raymond Camden
01/19/11 12:12 P
Teed,
Rob Parkhill
01/19/11 12:59 P
Rob,
Rick Faircloth
01/19/11 01:07 P
It worked for me locally.
Rick Faircloth
01/19/11 01:03 P
Glad it's working!
Rick Faircloth
01/19/11 02:08 P
Teed,
Rick Faircloth
01/19/11 12:57 P
Just in case, heres the rest of the code.
Teed Younger
01/18/11 11:39 A
Top  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Teed Younger
01/18/2011 10:01 AM

Hi I have a jquery created form that takes the user defined values and displays them in a list/s. However, no matter what I have tried, it wont allow me to insert an ampersand or some other special characters. I tried ascii code as well as escaping with forward and back slashes, but nothing has worked. Does anyone know how to escape special characters in the input field? Thanks in advance.

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Raymond Camden
01/18/2011 10:55 AM

I may not be understanding you right. Are you tying to set a value like this Ray & Ray as the value of a text field? > > Hi I have a jquery created form that takes the user defined values and displays them in a list/s. However, no matter what I have tried, it wont allow me to insert an ampersand or some other special characters. I tried ascii code as well as escaping with forward and back slashes, but nothing has worked. Does anyone know how to escape special characters in the input field? Thanks in advance.

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Teed Younger
01/18/2011 11:08 AM

Yes Raymond, that is correct. Specifically one I ran across the issue with is.... A&K The jQuery form does not like the ampersand for some reason. My other form fields accepts the & code just fine as cf session values. ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Raymond Camden
01/18/2011 11:12 AM

So to be clear, you are doing something a bit like this: <html> <head> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>; <script> $(document).ready(function() {   var s = "Ray & Ray";   $("#testField").val(s); }) </script> </head> <body> <input id="testField"> </body> </html> Except in your case, the form field was dynamic (created and inserted into the DOM by jQuery)? ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Teed Younger
01/18/2011 11:25 AM

lol well being very new to jQuery, not sure if thats what I have or not. So here is the code. <script src="http://www.google.com/jsapi"></script>; <script> // Load jQuery google.load("jquery", "1.4.2"); google.setOnLoadCallback(function(){   $(document).ready(function(){     $('.add-product').live('click', function(){       var productContainer = $(this).parents('.product');       var newProduct = $(productContainer).clone();       $(newProduct).find('.product-input').val('');              var vendorProductContainer = $(productContainer).parents('.vendor-products');       $(vendorProductContainer).append(newProduct);       $(productContainer).find('.add-product').hide();                    return false;     });     $('.add-vendor').live('click', function(){       var vendorContainer = $(this).parents('.vendor');                   //clone the vendor       var newVendor = $(vendorContainer).clone();       $(newVendor).find(':input').val('');              //remove all but the first products       $(newVendor).find('.product:gt(0)').remove();              $(vendorContainer).after(newVendor);       $(newVendor).find('.add-product').show();       $(vendorContainer).find('.add-vendor').hide();       return false;     });          $('#submit').click(function(){       $('#results').html('Loading...');              var items = {};              $('.product-grouping').each(function(i,e){         var title = $(e).find('legend').html();         items[title] = {};         items[title]['category'] = $(e).find('.category').val();         items[title]['vendors'] = {};         $(e).find('.vendor').each(function(vi,ve){           var products = [];           var v = $(ve).find('.vendor-input').val() || 'vendor ' + (vi+1);                      $(ve).find('.product-input').each(function(pi,pe){             products.push($(pe).val());           });           items[title]['vendors'][v] = products;         });                });              $.ajax({         type: 'GET',         url: 'action.cfm?data=' + JSON.stringify(items),         dataType: 'html',         //complete: function(data){           //$('#results').html(data.responseText);           //$('#results').empty();           //$('#vendorProductList').show();         success: function() {                            $('#results').empty();                                  var vendorProductListHTML = 'vendorProductList.cfm?' + new Date().getTime();           //alert(calendarEventsHTML);           $('#vendorProductList').empty().hide();           $('#vendorProductList').load(vendorProductListHTML);           $('#vendorProductList').fadeIn(250);                                          //$('#vendorProductList').show();         }       });                    });          $('#add-item').click(function(){       var item = $('.product-grouping:last').clone();       $(item).find('.vendor:gt(0)').remove();       $(item).find('.product:gt(0)').remove();       $(item).find(':input').val('');       $(item).find('.add-product').show();       $(item).find('.add-vendor').show();       var itemIdx = $('.product-grouping').size() + 1;       $(item).find('legend').html('Item ' + itemIdx);       $('#items').append(item);     });        }); }); </script> ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Teed Younger
01/18/2011 11:34 AM

Well it seems part of my code was cut out due to line limitations here. I think thats most of it and probably the code you need to look at anyway. Thanks again for your help! ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Raymond Camden
01/18/2011 11:38 AM

Where is the portion setting the field? You can use pastebin to share the code. It's better for stuff like this. ----- Excess quoted text cut - see Original Post for more ----- -- =========================================================================== Raymond Camden, ColdFusion Jedi Master Email    : ray@camdenfamily.com Blog      : www.coldfusionjedi.com AOL IM : cfjedimaster Keep up to date with Android news: http://www.andro

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Teed Younger
01/18/2011 11:49 AM

Ok hope I did this correctly. http://pastebin.com/tX731HvH This is the code for the form. Is that what you were asking for... setting the field? ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Raymond Camden
01/18/2011 12:15 PM

Nope, I'm not seeing it in that pastebin. ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Teed Younger
01/18/2011 12:24 PM

What about the second pasteBin? Maybe it would be easier to view my live application? http://www.teed-younger.com/pageBuilder/template.cfm >Nope, I'm not seeing it in that pastebin.

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Raymond Camden
01/18/2011 02:09 PM

So on the URL you sent, how do I reproduce the issue? ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Teed Younger
01/18/2011 02:54 PM

I apologize, I thought I described how to reproduce. The cross reference for section almost at the bottom of the page. You will see a vendors text field and a product text field. Make sure you click the button under the cross reference form section. The other submits the page to my action page. Try inserting text with an ampersand and watch it "freeze" up. Well it will say loading... but wont actually load the for results. Then refresh the page and remove the ampersand and you will see normal text strings work. Other special characters will work when escaped with back slashes. Just seems to be a few that wont work period. >So on the URL you sent, how do I reproduce the issue?

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Raymond Camden
01/18/2011 04:31 PM

I don't see that. I clicked "add item" (you said to click 'the button' I assume you mean that). This made a new form with the label Item 2. You said insert text but didn't say where. I assume you mean the first form field in the Item 2 section? I typed dee&ee and nothing happened. Was I supposed to do anything else? Like click add vendor perhaps? There is a _lot_ of stuff going on here and it's not quite clear what you mean. ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Teed Younger
01/18/2011 04:50 PM

ok disregard everything except the Cross Reference Form near the bottom of the page. Right above the address and contact info. First in the Vendors field type any text...try "Foo" Then type any text in the products field....."foofoo" Then click the submit button UNDER the Cross Reference Form...below the two fields you just filled out. Should return an unordered list of the values you just supplied. Now, refresh the page and take the same text or any other simple text and try to add an ampersand in with it in either field......"Foo&foofoo" Then when you click the same submit button again, the list wont display...it just hangs up on the ampersand, which I definately will need to be able to use. Again, I apologize for not being able to adequately describe my issues. I'm trying to learn lavascript and jQuery and still very new to all this. I hope this post helps in clearing up the confusion. ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Raymond Camden
01/18/2011 05:10 PM

So in Chrome I turned on the developer tools and looked at your network request. You should do the same (or use Firebug). I saw this error immediately: Request URL:http://www.teed-younger.com/pageBuilder/action.cfm?data={%22Item%201%22:{%22vendors%22:{%22mm%22:[%22mm&mm%22]}}} Request Method:GET Status Code:500 JSON parsing failure: Unexpected end of JSON string So the issue seems to be around the JSON serialization of your data. There is nothing inheritly wrong with & signs for sure - but it's not being escaped in the URL. Just switch your method to POST. On your back end, ensure you switch from url.data to form.data. ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Teed Younger
01/18/2011 07:53 PM

The ajax function...I switched to type= POST Then I switched <cfset results = deserializeJSON(url.data)> to <cfset results = deserializeJSON(FORM.data)> That didnt work either. I also added an alert function at the end of my ajax function. So then when I try to add the amp, it throws an error alert. I also think I may be using a cf tag or function my hosting site doesnt like and restricts. I cant seem to get this application to work from my remote. Thats no big deal since this is a local application anyway. ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Raymond Camden
01/18/2011 11:21 PM

When I run your site - the url you sent earlier - I'm still seeing GET requests, not POSTs. ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Teed Younger
01/18/2011 11:39 PM

Try this instead. I reverted back to an old copy in another folder. http://www.teed-younger.com/pagebuilder2/template.cfm That should have the POST request. ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Azadi Saryev
01/19/2011 03:45 AM

Your data is still being submitted using GET request: GET http://www.teed-younger.com/pagebuilder2/action.cfm?data={%22Item%201%22:{%22vendors%22:{%22Foo%22:[%22bar&bar%22]}}} - that's the request being sent to server after clicking 'submit' button. if you check in firebug the params sent with the request you will see: bar"]}}} data    {"Item 1":{"vendors":{"Foo":["bar because of a GET request and a & in field value your action page sees the request as having 2 url parameters, and your deserializeJSON() function fails because it can't see a valid json object. this javascript in your page needs to be changed to send a POST request: $.ajax({                  type: 'GET',                  url: 'action.cfm?data=' + JSON.stringify(items),                  dataType: 'html',                  //complete: function(data){                      //$('#results').html(data.responseText);                      //$('#results').empty();                      //$('#vendorProductList').show();                  success: function() {                      $('#results').empty();                      var vendorProductListHTML = 'vendorProductList.cfm?' + new Date().getTime();                      //alert(calendarEventsHTML);                      $('#vendorProductList').empty().hide();                      $('#vendorProductList').load(vendorProductListHTML);                      $('#vendorProductList').fadeIn(250);                      //$('#vendorProductList').show();                  }              }); Azadi On 19/01/2011 12:31 , Teed Younger wrote: ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Teed Younger
01/19/2011 07:58 AM

I dont understand because I have changed and uploaded that ajax function When I view and debug in firebug, I get a GET and a POST: 1920 x 1742 Firebug's log limit has been reached. 0 entries not shown.    Preferences   POST http://teed-younger.com/pagebuilder2/action.cfm?...:{%22vendors%22:{%22vendor%22:[%22product%22]}}} POST http://teed-younger.com/pagebuilder2/action.cfm?data={%22Item%201%22:{%22vendors%22:{%22vendor%22:[%22product%22]}}}    200 OK     202ms   jquery.min.js (line 130) GET http://teed-younger.com/pagebuilder2/vendorProductList.cfm?1295441582231 GET http://teed-younger.com/pagebuilder2/vendorProductList.cfm?1295441582231    200 OK     119ms   jquery.min.js (line 130) POST http://teed-younger.com/pagebuilder2/action.cfm?...:{%22vendors%22:{%22vendor%22:[%22product%22]}}} POST http://teed-younger.com/pagebuilder2/action.cfm?data={%22Item%201%22:{%22vendors%22:{%22vendor%22:[%22product%22]}}}    200 OK     466ms   jquery.min.js (line 130) GET http://teed-younger.com/pagebuilder2/vendorProductList.cfm?1295441604319 GET http://teed-younger.com/pagebuilder2/vendorProductList.cfm?1295441604319    200 OK     118ms   jquery.min.js (line 130) When I change the url.data to FORM.data in my JSON <cfset results = deserializeJSON(url.data)> I get a element data undefined. ----- Excess quoted text cut - see Original Post for more -----                  > type: 'GET',                  > url: 'action.cfm?data=' + JSON.stringify(items),                  > dataType: 'html',                  > //complete: function(data){                      > //$('#results').html(data.responseText);                      > //$('#results').empty();                      > //$('#vendorProductList').show();                  > success: function() { >                      > $('#results').empty(); >                      > var vendorProductListHTML = > 'vendorProductList.cfm?' + new Date().getTime();                      > //alert(calendarEventsHTML);                      > $('#vendorProductList').empty().hide();                      > $('#vendorProductList').load(vendorProductListHTML);                      > $('#vendorProductList').fadeIn(250); >                      > //$('#vendorProductList').show();                  > }              ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Teed Younger
01/19/2011 08:51 AM

Crap post cut off again. wanted to show the code I now have for the ajax $.ajax({         type: 'POST',         url: 'action.cfm?data=' + JSON.stringify(items),         dataType: 'html',         //complete: function(data){           //$('#results').html(data.responseText);           //$('#results').empty();           //$('#vendorProductList').show();         success: function() {                            $('#results').empty();                                  var vendorProductListHTML = 'vendorProductList.cfm?' + new Date().getTime();           //alert(calendarEventsHTML);           $('#vendorProductList').empty().hide();           $('#vendorProductList').load(vendorProductListHTML);           $('#vendorProductList').fadeIn(250);                                          //$('#vendorProductList').show();         }       });                    });

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Raymond Camden
01/19/2011 09:26 AM

Your JSON data is _still_ in the URL. Right there: url: 'action.cfm?data=' + JSON.stringify(items) You need to include it in the post data instead. ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Rick Faircloth
01/19/2011 09:41 AM

Hi, Teed... If I'm not mistaken, the GET that Firebug is showing is from the .load function in the success part of the .ajax function. The problem with the '&' is that it's not being parsed correctly.  Normally, without any disrupting character in the json, when you submit, you get data in this format: data  {"Item 1":{"vendors":{"Vendor One":["V1-P1"]}}} When a disruptive character is used, such as an '&', then the data sent is corrupted and looks like this when it's sent through the .ajax function: A":["V1-P1"]}}}   data  {"Item 1":{"vendors":{"K If the '&' is changed to 'and', then the data is formatted correctly: data  {"Item 1":{"vendors":{"K and A":["V1-P1"]}}} I'm not sure how to correct the parsing error at the moment.  Perhaps this will spur someone's thinking in the right direction. Rick Crap post cut off again. wanted to show the code I now have for the ajax $.ajax({         type: 'POST',         url: 'action.cfm?data=' + JSON.stringify(items),         dataType: 'html',         //complete: function(data){    //$('#results').html(data.responseText);           //$('#results').empty();           //$('#vendorProductList').show();         success: function() {                            $('#results').empty();                            var vendorProductListHTML = 'vendorProductList.cfm?' + new Date().getTime();           //alert(calendarEventsHTML);    $('#vendorProductList').empty().hide();    $('#vendorProductList').load(vendorProductListHTML);           $('#vendorProductList').fadeIn(250);                            //$('#vendorProductList').show();         }       });                    });

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Teed Younger
01/19/2011 10:11 AM

lol Hey Rick, thanks for the tips and ideas. I do understand that the & is not being parsed correctly, just not sure why. Other than to say that the & and % characters are sometimes used to pass dynamic urls so maybe they are "reserved" in a manner for that reason Raymond has suggested I should "move" the url: action.cfm?data=JSON.stringify(items) to my POST data. Just very confused as to what that means. Not sure what or where the post data is. lol I about ready to throw my laptop in the garbage! lol ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Raymond Camden
01/19/2011 10:16 AM

Check the docs for ajax() method: http://api.jquery.com/jQuery.ajax/ It specifically mentions the data argument which is used to pass data to the server. So change your URL to _just_ action.cfm. And pass the data in the data attribute instead. > > lol Hey Rick, thanks for the tips and ideas. I do understand that the & is not being parsed correctly, just not sure why. Other than to say that the & and % characters are sometimes used to pass dynamic urls so maybe they are "reserved" in a manner for that reason > >  Raymond has suggested I should "move" the > url: action.cfm?data=JSON.stringify(items) > > to my POST data. Just very confused as to what that means. Not sure what or where the post data is. lol I about ready to throw my laptop in the garbage! lol

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Rick Faircloth
01/19/2011 11:12 AM

> I about ready to throw my laptop in the garbage! I totally understand that frustration.  When I was first trying to implement jQuery .ajax into my CF applications I was on the edge of a meltdown. Hang in there, however, a solution exists, and with diligence you will find it and the sun will shine! We'll get there, hang on! There may need to be some additional parsing of the data being delivered to the backend (CF) side on the action.cfm page to deal with disruptive characters.  Before going that route, I'm waiting to see what emerges from the community as potential solutions. And like you, I'm not sure what Ray means by "move" the data to the post, or whatever exactly he wrote. It seems to me that the "url: action.cfm?data=JSON.stringify(items)" is the equivalent of action="action.cfm" in a typical post. How 'bout explaining what you mean for both of us, Ray... Rick lol Hey Rick, thanks for the tips and ideas. I do understand that the & is not being parsed correctly, just not sure why. Other than to say that the & and % characters are sometimes used to pass dynamic urls so maybe they are "reserved" in a manner for that reason Raymond has suggested I should "move" the url: action.cfm?data=JSON.stringify(items) to my POST data. Just very confused as to what that means. Not sure what or where the post data is. lol I about ready to throw my laptop in the garbage! lol ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Rob Parkhill
01/19/2011 11:21 AM

Rick and Teed, What Ray means is that you can remove the need to parse the data into JSON if you just change it to a regular POST action. Instead of referencing URL.DATA and de-serializing the JSON, just access the FORM object. So, FORM.name1 or whatever instead of accessing DATA.name1. You will have to update the action.cfm file to handle a different source for the query params (or whatever you are doing with the data) but the POST data will be fine with the & and %, as you aren't putting it in the URL where it is getting truncated and messed up. Hopefully that clears up what Ray is suggesting, or I am totally wrong and Ray will correct me. Rob

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Raymond Camden
01/19/2011 12:12 PM

Rob explained it - sorry was on the phone. ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Teed Younger
01/19/2011 12:49 PM

Ok so if I understand this, it's back to a simple cfparam passing the FORM values? Correct me if I'm wrong, but with a struct, form values wont work, since a struct is a complex string. I need a punching bag in my office!! hahaha >Rob explained it - sorry was on the phone.

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Rob Parkhill
01/19/2011 12:59 PM

Teed, Form values are stored in a struct.  Form.name1, etc.  All you have to do is pass it in (via a post, just like a regular form action page, the only difference is that you are doing it with AJAX). As for Ricks point, you would have to loop over the various values in the form struct if you have the fields named the same, the values will get passed as a comma separated list. Rob On Wed, Jan 19, 2011 at 12:40 PM, Teed Younger <teedyounger@hotmail.com>wrote: ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Rick Faircloth
01/19/2011 01:07 PM

Rob, And the looping part is really the issue.  Currently, the form data is being handled and formatted on the client-side via jQuery with looping also on the backend in CF. The frontend jQuery and the backend CF would need to both be rewritten to handle it as you're proposing, which will be the best solution long-term. Rick Teed, Form values are stored in a struct.  Form.name1, etc.  All you have to do is pass it in (via a post, just like a regular form action page, the only difference is that you are doing it with AJAX). As for Ricks point, you would have to loop over the various values in the form struct if you have the fields named the same, the values will get passed as a comma separated list. Rob On Wed, Jan 19, 2011 at 12:40 PM, Teed Younger <teedyounger@hotmail.com>wrote: ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Rick Faircloth
01/19/2011 12:51 PM

I probably don't understand enough to make this judgment, but it seems that accessing the form object may not work since the form fields don't have unique names. The form values that are being processed is in the form of: Vendor - product - product Vendor - product - product And the current JSON.stringify() method creates this output for the post... {"Item 1":{"vendors":{"Vendor One":["V1-P1"]}}} ...instead of name-value pairs. I haven't had to process data in this form before. However, a workaround that is easy on the coding side, but more demanding on the input side (which is never a good choice) is to use the %26 in place of the '&'. The vendor could now be entered as K %26 A and would be returned for display as K & A. Rick Rick and Teed, What Ray means is that you can remove the need to parse the data into JSON if you just change it to a regular POST action. Instead of referencing URL.DATA and de-serializing the JSON, just access the FORM object. So, FORM.name1 or whatever instead of accessing DATA.name1. You will have to update the action.cfm file to handle a different source for the query params (or whatever you are doing with the data) but the POST data will be fine with the & and %, as you aren't putting it in the URL where it is getting truncated and messed up. Hopefully that clears up what Ray is suggesting, or I am totally wrong and Ray will correct me. Rob

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Teed Younger
01/19/2011 01:01 PM

OMG! that worked Rick! All this crap just to get a freaking & in the form! lol So the only downside to this solution is the user being forced to input as %26? Again, this is strictly a back room application, so I dont care that the url doesnt parse the & correctly, as long as I can get the & in the string somehow! lol Teed ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Rick Faircloth
01/19/2011 01:03 PM

It worked for me locally. Does it work on your current app throughtout the process to the final .html file that's created? OMG! that worked Rick! All this crap just to get a freaking & in the form! lol So the only downside to this solution is the user being forced to input as %26? Again, this is strictly a back room application, so I dont care that the url doesnt parse the & correctly, as long as I can get the & in the string somehow! lol Teed ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Teed Younger
01/19/2011 01:38 PM

Yes Rick it works and carries the list values from vendorProductList.cfm throughout the whole application. I tried as Rob suggested, but like you were saying, since this is a struct storing form values that are looped through, I think it would require a total rewrite of the application. That may be the BEST solution, but not one I want to try at this point..lol. ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Rick Faircloth
01/19/2011 02:08 PM

Glad it's working! Yes Rick it works and carries the list values from vendorProductList.cfm throughout the whole application. I tried as Rob suggested, but like you were saying, since this is a struct storing form values that are looped through, I think it would require a total rewrite of the application. That may be the BEST solution, but not one I want to try at this point..lol. ----- Excess quoted text cut - see Original Post for more ----- url >doesnt parse the & correctly, as long as I can get the & in the string >somehow! lol > >Teed

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Teed Younger
01/19/2011 02:44 PM

Thanks to all of you for helping me and having the patience lol. Still learning! now if I can just get the list to display alphabetically I'll be good to go! lol Think I'll leave that for another day this week. Have other matters to attend to as well. Thanks again! Teed ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Rick Faircloth
01/19/2011 12:57 PM

Teed, Here's a 'solution' that will get you where you need to be, but is not a great one for the user. Instead of typing K&A in the vendor field, just use K%26A (hex code) and you'll get the K&A output. There'll probably need to be a different form setup on the front end or different processing on the backend or perhaps both, to make this work with inserting an & into the field. But the %26 method may at least buy you some time. The $.ajax section will look like this: $.ajax({     type: 'post',     url: 'action.cfm?data=' + JSON.stringify(items),     dataType: 'html',     success: function() {         $('#results').empty();                                var vendorProductListHTML = 'vendorProductList.cfm?' + new Date().getTime();         $('#vendorProductList').empty().hide();    $('#vendorProductList').load(vendorProductListHTML);         $('#vendorProductList').fadeIn(250);                  } }); Rick lol Hey Rick, thanks for the tips and ideas. I do understand that the & is not being parsed correctly, just not sure why. Other than to say that the & and % characters are sometimes used to pass dynamic urls so maybe they are "reserved" in a manner for that reason Raymond has suggested I should "move" the url: action.cfm?data=JSON.stringify(items) to my POST data. Just very confused as to what that means. Not sure what or where the post data is. lol I about ready to throw my laptop in the garbage! lol ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Teed Younger
01/18/2011 12:05 PM

Also here is my action page code that loops though the struct and display in the list. Then the list is saved with cffile, output to vendorProductList..cfm and displayed BACK on my original template as a list. Confusing I guess! I know it is to me. lol http://pastebin.com/HSuk9d74 ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Teed Younger
01/18/2011 11:39 AM

Just in case, heres the rest of the code. $.ajax({         type: 'GET',         url: 'action.cfm?data=' + JSON.stringify(items),         dataType: 'html',         //complete: function(data){           //$('#results').html(data.responseText);           //$('#results').empty();           //$('#vendorProductList').show();         success: function() {                            $('#results').empty();                                  var vendorProductListHTML = 'vendorProductList.cfm?' + new Date().getTime();           //alert(calendarEventsHTML);           $('#vendorProductList').empty().hide();           $('#vendorProductList').load(vendorProductListHTML);           $('#vendorProductList').fadeIn(250);                                          //$('#vendorProductList').show();         }       });                    });          $('#add-item').click(function(){       var item = $('.product-grouping:last').clone();       $(item).find('.vendor:gt(0)').remove();       $(item).find('.product:gt(0)').remove();       $(item).find(':input').val('');       $(item).find('.add-product').show();       $(item).find('.add-vendor').show();       var itemIdx = $('.product-grouping').size() + 1;       $(item).find('legend').html('Item ' + itemIdx);       $('#items').append(item);     });        }); }); </script> ----- Excess quoted text cut - see Original Post for more -----


<< Previous Thread Today's Threads Next Thread >>

Search jquery

May 20, 2013

<<   <   Today   >   >>
Su Mo Tu We Th Fr Sa
       1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31   

Designer, Developer and mobile workflow conference