[jQuery] Re: Finding ID within Ajax response
Just a guess here - is it possible that jquery will not recognize nodes that are loaded after the document is first rendered? Do you need to rebind? On Apr 13, 4:28 pm, Nic Hubbard wrote: > Ok, my test now reflects your suggestions. But, sadly, none of that > helped, it is still returning undefined. :( > > On Apr 13, 1:03 pm, Nic Luciano wrote: > > > > > Hey Nic, > > > I have a couple small recommendations- hopefully one will fix the issue. > > > Try using $.get() instead of $.ajax, and specify "type" option as "html"- > > alternatively, you can use $.load() if your ultimate purpose is to inject > > this HTML into DOM. > > > In addition rather than using find(), just select by ID as a subset of the > > DOM node.. > > > alert($(html).find("#test") becomes > > alert($("#test", html)); > > > Hope some of this helps... cheers! > > > Nic Luciano > > Senior Web Developer @ > > AdaptiveBluehttp://www.twitter.com/niclucianohttp://www.linkedin.com/in/nicluciano > > > On Mon, Apr 13, 2009 at 3:35 PM, Nic Hubbard wrote: > > > > Nope, that does not work either. > > > > On Apr 13, 12:20 pm, Jack Killpatrick wrote: > > > > Maybe try: > > > > > success: function(html){ > > > > alert($(html).find('form').attr('action')); > > > > > I had some issues in the past using form id's with the jquery form > > > > plugin, but usually getting it using 'form' worked. > > > > > That said, since the response isn't in the DOM yet, I'm not sure if that > > > > might present an issue (too/instead). > > > > > - Jack > > > > > Nic Hubbard wrote: > > > > > Yes, this is very odd. I have tried it quite a few ways, but I can > > > > > never target the form. Any other ideas? > > > > > > It is frustrating because I really need to target a form in the html > > > > > response... > > > > > > On Apr 13, 11:45 am, James wrote: > > > > > >> That's strange. I can't get it to work either and I'm getting the > > > > >> same > > > > >> results as you (I can get #test2, but not #test). I've even truncated > > > > >> the response down to as if you're only receiving the part and > > > > >> it still doesn't work. I'd be interested in seeing what happens here > > > > >> too. > > > > > >> On Apr 13, 6:47 am, Nic Hubbard wrote: > > > > > >>> Test page to show the problem:http://www.puc.edu/dev/tests/ajax-test > > > > > >>> On Apr 13, 9:33 am, Nic Hubbard wrote: > > > > > I am pulling my hair out over this. I swear that this is a bug. > > > > > For some reason, I CANNOT target any forms within the html > > > > response. > > > > I have tried very simple examples and it still won't work. Here is > > > > what I have, that still returns undefined: > > > > > HTML: > > > > http://test.com";> > > > > this is my text > > > > > > > > > jQuery: > > > > success: function(html){ > > > > alert($(html).find("#test").attr('action')); > > > > alert($(html).find("#test2").text()); > > > > > } > > > > > #test2 works, but #test never does, and it seems this is because it > > > is > > > > a form. Have I done something wrong here? Can I not target a > > > > form? > > > > > On Apr 12, 4:35 pm, Nic Hubbard wrote: > > > > > > I have an ajax GET call that returns the HTML of a page on my > > > server. > > > > > Within that page is a form with a specific ID. I know it is > > > > > there, > > > I > > > > > can see it in the response in Firebug, but when I try to get > > > > > attributes of that ID, it always returns undefined! What have I > > > done > > > > > wrong here? > > > > > > success: function(html){ > > > > > > $(html).find('#main_form').each(function() { > > > > > var linking_data = $(this).serialize(); > > > > > var form_action = $(this).attr('action'); > > > > > alert(form_action); > > > > > > }); > > > > > } > > > > > > I have tried to not use each() and that still returns undefined. > > > > > I > > > > > don't get it.
[jQuery] Re: General question regarding speed
Thanks for your thoughts. I have datasets of varying sizes from a few rows to several thousand. I do appreciate the flexibility that returning json gives me on the client side although I've done lots of server side manipulation in the past. Intuitively, this seems to mix apples and oranges though. Thanks again for your thoughts on the matter. On Mar 24, 2:24 pm, James wrote: > Additionally, since you said its for your Intranet, you probably > wouldn't have much lag so I think speed either way. JSON would > probably have less data being transferred, but more overhead on the > client-side to process the data. HTML would have more data being > transferred, but less processing if all you're doing is just dropping > in the HTML. > > Of course all of this depends on how much data is being returned. > > On Mar 24, 8:21 am, James wrote: > > > > > I assume you're talking about returning data via AJAX? > > Returning HTML is probably the fastest if all you're doing is just > > inserting the HTML into the DOM. > > However, returning JSON gives you a lot more flexibility if you > > actually want to do something with the returned data, such as client- > > side calculations, formatting, parsing error statuses, or dropping > > data into different parts of the DOM (not just in one place), etc. > > > I personally favored the JSON route even if I were merely just > > dropping in data on the page since it sort of keeps the HTML out of > > the server-side scripting (as that's usually the source of my AJAX > > responses.) I'd rather have HTML inside my JavaScript coding than in > > my server-side (e.g. PHP, ASP) coding. > > > On Mar 24, 3:36 am, finco wrote: > > > > I am trying to figure the best way to maximize performance with data > > > returned from ASP pages. > > > > Option one - return data in an HTML table. Let the host page's css > > > format the table. > > > > Option two - return json data from the asp page and let the browser > > > drop the data into a table and still let the host page do the final > > > formatting. > > > > I guess the question is where the faster/least amount of processing > > > time and transport of data is used. Other items of note - the > > > application is an intranet where all users will have javascript > > > enabled. > > > > Your collective wisdom is greatly appreciated.
[jQuery] General question regarding speed
I am trying to figure the best way to maximize performance with data returned from ASP pages. Option one - return data in an HTML table. Let the host page's css format the table. Option two - return json data from the asp page and let the browser drop the data into a table and still let the host page do the final formatting. I guess the question is where the faster/least amount of processing time and transport of data is used. Other items of note - the application is an intranet where all users will have javascript enabled. Your collective wisdom is greatly appreciated.
[jQuery] Re: .getJSon
Thanks for the code snippet Josh. It's exactly what I was looking for. Certainly load works as well. At this point I am trying to understand various options for producing data on an intranet. In the past I have written asp pages which format the HTML and then use ajax (with or without jquery) to insert the dormatted data. I have assumed that I might see a performance benefit by transporting raw data and formatting it locally. I'm not sure if that holds true. Any thoughts? On Mar 14, 7:05 pm, Josh Powell wrote: > What I don't like about that method is the loss of ease of updating > and reuse of code later on. If you stick it in a table coming back, > and need the some data somewhere else you cannot reuse it. Also, > changing things on server side requires recompiling in a java > environment, which is a drag for html development. In a PHP > environment it wouldn't be as big of a deal though. > > It's also a matter of separating the data from the layout. I prefer > making an ajax request to retrieve data and do all of my layout/ > styling and interactivity in javascript. That way it never becomes > confusing where to go to update things. If it's a data issue, you go > to the server, if it's a layout/styling issue then the problem is in > the javascript. When you start breaking that line by putting html in > the server side code, things can get messy. > > That said, what you are talking about is a perfectly valid way to > code. > > On Mar 14, 2:10 pm, donb wrote: > > > Then I must be missing something: > > > $("#placetoinsert").load("path/to/url"); > > > would do the same thing, with the tableHTML constructed on the server > > side. > > > On Mar 14, 5:02 pm, Josh Powell wrote: > > > > Because it puts it in the javascript and lets you easily manipulate it > > > with javascript. If you get html back from the server, it's more > > > difficult to manipulate. > > > > $.getJson('path/to/url', function(data) { > > > var tableHTML = ''; > > > $.each(data.aaData, function() { > > > tableHTML += '' + this[0] + '' + this[1] + > > > ''; > > > }); > > > tableHTML += ''; > > > $('#placeToInsert').append(tableHtml); > > > > }); > > > > On Mar 14, 12:30 pm, donb wrote: > > > > > If that's all your going to do with it, why not return a table from > > > > the server and simply .load() it? No transformation required in that > > > > case. > > > > > On Mar 14, 9:23 am, finco wrote: > > > > > > Sorry if this is a duplicate post - doesn't look like the last one > > > > > went through. > > > > > > I've seen several examples of how to process json data with .each when > > > > > the field names come over with json. My data, howver, looks like the > > > > > following: > > > > > > {"aaData": [ > > > > > ["1001-00-1535.000","Tenant Improvements"], > > > > > ["1001-00-1558.000","Selling costs"], > > > > > ["1001-00-1560.000","Financing Fees"], > > > > > ["1001-00-1560.001","Financing Fees - Legal"], > > > > > ["1001-00-1565.000","Lease Costs"], > > > > > ["1001-00-1565.001","Lease Costs -Legal"], > > > > > ["1001-00-1565.002","Lease Costs - Brokerage"], > > > > > ["1001-00-1570.000","Legal Fees"] > > > > > ]} > > > > > > How would I drop this data into a table? > > > > > > Thanks in advance for your help.
[jQuery] .getJSon
Sorry if this is a duplicate post - doesn't look like the last one went through. I've seen several examples of how to process json data with .each when the field names come over with json. My data, howver, looks like the following: {"aaData": [ ["1001-00-1535.000","Tenant Improvements"], ["1001-00-1558.000","Selling costs"], ["1001-00-1560.000","Financing Fees"], ["1001-00-1560.001","Financing Fees - Legal"], ["1001-00-1565.000","Lease Costs"], ["1001-00-1565.001","Lease Costs -Legal"], ["1001-00-1565.002","Lease Costs - Brokerage"], ["1001-00-1570.000","Legal Fees"] ]} How would I drop this data into a table? Thanks in advance for your help.
[jQuery] JSON Newbie
I'm new to jquery and json. I've looked at lots of examples of how to process json data but they all seem to have field names that come across in the data and are used in the foreach processing. My data looks like this: {"aaData": [ ["1001-00-1535.000","Tenant Improvements"], ["1001-00-1558.000","Selling costs"], ["1001-00-1560.000","Financing Fees"], ["1001-00-1560.001","Financing Fees - Legal"], ["1001-00-5799.000","Bad Debt Expense"], ["1001-00-5800.000","Amortization"], ["1001-00-5805.000","Depreciation"], ["1001-00-.000","Suspense"] ]} I'm trying to drop these two fields into table rows. Can someone point me in the right direction as to how I reference the json data. Thanks for your help.
[jQuery] Re: Form Plugin
Is there a way to make this dynamic? I have ~ 100 lines that need to be written into a table of data which a check box indicating status of a project (complete or not). Each checkbox has an id="check1" or "check2" etc. What I'm looking to do is to trigger a function that submits ProcessThe Data.asp?ID=1 (which is done in the background without a page refresh. What you suggested works perfectly for submitting the entire form - I think I want to submit a simple URL and have it process in the background. On Apr 29, 4:34 pm, "Mike Alsup" <[EMAIL PROTECTED]> wrote: > > Can someone please point me in the right direction? I am using the > > form plugin and it works great on a form submit action. Is there a > > way I can use it on a click event on a checkbox or onblur for a text > > field to immediately save the user's data? Thanks in advance for your > > help. > > You can use the ajaxSubmit fn with any event you choose. For example, > > $('#myCheckbox').click(function() { > $('#myForm').ajaxSubmit({ > // options go here > }); > return false; > > }); > > Replace the 'click' fn above with 'blur' or whatever you need. > > Mike
[jQuery] Re: Form Plugin
Thanks - that's what I needed. On Apr 29, 4:34 pm, "Mike Alsup" <[EMAIL PROTECTED]> wrote: > > Can someone please point me in the right direction? I am using the > > form plugin and it works great on a form submit action. Is there a > > way I can use it on a click event on a checkbox or onblur for a text > > field to immediately save the user's data? Thanks in advance for your > > help. > > You can use the ajaxSubmit fn with any event you choose. For example, > > $('#myCheckbox').click(function() { > $('#myForm').ajaxSubmit({ > // options go here > }); > return false; > > }); > > Replace the 'click' fn above with 'blur' or whatever you need. > > Mike
[jQuery] Form Plugin
Can someone please point me in the right direction? I am using the form plugin and it works great on a form submit action. Is there a way I can use it on a click event on a checkbox or onblur for a text field to immediately save the user's data? Thanks in advance for your help.