Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Extracting specific code from an AJAX request. 1

Status
Not open for further replies.

travisbrown

Technical User
Dec 31, 2001
1,016
So I'm in this situation where I need to call in a chunk of code from another page. Not the whole page, just a table inside a div with an id="SelectedContent".

I have no problem pulling in the entire page content using an AJAX request. Question is, what is the best method for parsing out just the required code?

My first through is use regex on the returned string, but my first thoughts are usually unwieldy.
 
I have no problem pulling in the entire page content using an AJAX request. Question is, what is the best method for parsing out just the required code?

Surely the question is, why do you want to pull back a whole page and waste both your bandwidth and that of your users when you are going to throw most of it away?

Why not simply pull back the small amount of data only, and simply write that into the page?

It's a very common model, and you don't have to write the same code twice if you use includes / templates.

Doing this would also avoid the need to write potentially complex parsing routines unnecessarily.

Hope this helps,
Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

Dan's Page [blue]@[/blue] Code Couch:
Code Couch Tech Snippets & Info:
 
Surely the question is, why do you want to pull back a whole page and waste both your bandwidth and that of your users when you are going to throw most of it away?

Why not simply pull back the small amount of data only, and simply write that into the page?

It's a very common model, and you don't have to write the same code twice if you use includes / templates.

Doing this would also avoid the need to write potentially complex parsing routines unnecessarily.

Hope this helps,
Dan

Hi Dan

Because I don't have access to the target page or its data components except in its assembled and served form. This is a special case where we are prototyping variations of a page and the client is using a CMS to produce static production pages. I need to pull in frequently changing data from one of these static pages to match the data on the variations with the control page.

I'm well aware of the advantages of templating and includes. They just aren't an option at this stage. When we get into a production model, then it's a different case.
 
Thanks Dian. That's what I was looking for. Accessing the DOM of the response.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top