954,561 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

$.post code returns a whole page. how to get content of a id?

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());
   }
   );
Virangya
Junior Poster
122 posts since Apr 2010
Reputation Points: 10
Solved Threads: 0
 

...

Airshow
WiFi Lounge Lizard
Moderator
2,682 posts since Apr 2009
Reputation Points: 321
Solved Threads: 372
 

...

Virangya
Junior Poster
122 posts since Apr 2010
Reputation Points: 10
Solved Threads: 0
 

V,

I'm not sure I fully understand.

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

Airshow

Airshow
WiFi Lounge Lizard
Moderator
2,682 posts since Apr 2009
Reputation Points: 321
Solved Threads: 372
 

those html codes are added later, i cannot strip it...

Virangya
Junior Poster
122 posts since Apr 2010
Reputation Points: 10
Solved Threads: 0
 

I'm struggling with "later".

Do you mean: and ... do not appear in data and are therefore not available to be stripped?
and ... appear in data but you don't know how to strip them?
Airshow

Airshow
WiFi Lounge Lizard
Moderator
2,682 posts since Apr 2009
Reputation Points: 321
Solved Threads: 372
 

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

Virangya
Junior Poster
122 posts since Apr 2010
Reputation Points: 10
Solved Threads: 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

Airshow
WiFi Lounge Lizard
Moderator
2,682 posts since Apr 2009
Reputation Points: 321
Solved Threads: 372
 

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

Airshow
WiFi Lounge Lizard
Moderator
2,682 posts since Apr 2009
Reputation Points: 321
Solved Threads: 372
 

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!!

Virangya
Junior Poster
122 posts since Apr 2010
Reputation Points: 10
Solved Threads: 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

Airshow
WiFi Lounge Lizard
Moderator
2,682 posts since Apr 2009
Reputation Points: 321
Solved Threads: 372
 

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

link_umer
Newbie Poster
3 posts since Jan 2012
Reputation Points: 10
Solved Threads: 1
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: