0

hi,
my $.post code returns a whole page i want to get only content inside a id from that . this is my code it alerts null.
what's wrong with it..?

$(document).ready(function(){
	var url_select_file = "index.php";
 	$.post(url_select_file, { component: "tinymce_details", action: "selecticondata" },
   function(data){
	   //alert(data);
	   alert($(data).find('#ContentPane').html());
   }
   );
3
Contributors
11
Replies
14
Views
5 Years
Discussion Span
Last Post by link_umer
0

V,

I expect jQuery chokes on a full document with <!DOCTYPE ...> and a <head> full of metas etc.

Try stripping data down to <body>...</body> before submitting it to jQuery.

Stripping is best done with a regular expression, which you will need to develop or find. Searching the web for "javascript regular expression to find body element" gives plenty of results.

Airshow

0

V,

I expect jQuery chokes on a full document with <!DOCTYPE ...> and a <head> full of metas etc.

Try stripping data down to <body>...</body> before submitting it to jQuery.

Stripping is best done with a regular expression, which you will need to develop or find. Searching the web for "javascript regular expression to find body element" gives plenty of results.

Airshow

thanks Airshow for your reply.. i'm doing this with php and MVC as the design pattern. here i echo() results from my query on a page in Model, which is included in the controller and index page is where i view it, all the <!DOCTYPE ...> and HTML code are added later as i load the page,these html codes are with in index.php .
so anyway as far as i know since these html codes are added later somewhere after i echo() my results, i don't think i can edit , process other codes before submitting it to jQuery. :-/

0

V,

I'm not sure I fully understand.

Are you saying that <!DOCTYPE...> etc. are not served, or that it is served but you don't know how to strip it?

Airshow

0

I'm struggling with "later".

Do you mean:

  • <!DOCTYPE> and <head>...</head> do not appear in data and are therefore not available to be stripped?
  • <!DOCTYPE> and <head>...</head> appear in data but you don't know how to strip them?

Airshow

0

it does appear in data.. for example :

<!DOCTYPE> <html> ..<head>...</head>
<body>
<div id='ContentPane'>
</div>
</body>
</html>

results outputtted by my sql are inside this 'ContentPane' .. all the html added in to data is added some where after the sql return data.. these html are found in index.php
Thanx Airshow

0

OK, the best way to approach this is to handle ajax requests outside the MVC framework such that you have total control over what is returned.

If you can't do that, then try.

$(document).ready(function(){
	var url_select_file = "index.php";
	$.post(
		url_select_file,
		{ component: "tinymce_details", action: "selecticondata" },
		function(data){
			alert($(data).filter('#ContentPane').html());
		}
);

untested

All I have done is to change .find() to .filter() . It may work.

Airshow

0

V,

I have done some research for you and come to the conclusion that you can stay within the MVC framework by doing what is called "rendering a partial view".

As I understand the term, "partial views" can be used to build common page components for incorporation into whole pages as they are built, or served as ajax responses for incorporation by javascript into a previously-served page. Thus, you can serve an HTML snippet rather than an entire page, which is exactly what you want.

That is as much as I know. For more information, see your framework's documentation or try googling the name of your framework plus "partial view".

Airshow

0

OK, the best way to approach this is to handle ajax requests outside the MVC framework such that you have total control over what is returned.

If you can't do that, then try.

$(document).ready(function(){
	var url_select_file = "index.php";
	$.post(
		url_select_file,
		{ component: "tinymce_details", action: "selecticondata" },
		function(data){
			alert($(data).filter('#ContentPane').html());
		}
);

untested

All I have done is to change .find() to .filter() . It may work.

Airshow

ok thanks Airshow. i will try this, about partial views, i think i have a clear idea i think i'm not good at describing it, maybe because English is not my mother tongue. So, sorry about any misunderstandings. anyway, thanks a lot for your help! much appreciated! Have a nice New year!!

0

No worries, your English is fine. I was a little slow to understand but I think I got there.

Good luck and yes, Happy New Year.

Airshow

0

how to use ComboBox set value to TextFields and there are more than one text field and every textfield has different value from the other text fields if there is one text field combobox can set the value in it but if there is more than one textfield combobox insert the same value in it

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.