Muller Posted July 28, 2011 Share Posted July 28, 2011 Hiya, I'm trying to develop a new categories block. I'm using Ajax to get category.php and place the query result in the current "#center_column". However category.php returns an entire page, including <head> tags, etc. I wish to get only what's inside the body of category.php. Note: I can't get the entire thing and then filter the body and use that, for some reason jQuery's Ajax returns a 404 error if I try to get category.php as is. I can get test .phps that I created, but I can't get pages from the actual store. So the question is: How can I get what's inside the <body> of a page like category.php? Thanks in advance, I'm really losing my wits here Link to comment Share on other sites More sharing options...
Muller Posted July 28, 2011 Author Share Posted July 28, 2011 What I did so far is edit CategoryController, overwrite the run function and only included init, preProcess, process, and displayContent. Now it seems the Ajax response is indeed only the code of the body, but the response still gets a 404 error. Anyone have any experience with this? Link to comment Share on other sites More sharing options...
vivek tripathi Posted August 2, 2011 Share Posted August 2, 2011 Hi Muller you can use following jquery code block to get desire content from ajax response excluding header and footer $.ajax({ type:"POST", url: "category.php", data:"id="+id , success: function(data){ //create jquery object from the response html var $response=$(data); //query the jq object for the values var oneval = $response.filter('#center_column').text(); // you can use oneval value it simply return value inside div id centre_column excluding header footer } }); What I did so far is edit CategoryController, overwrite the run function and only included init, preProcess, process, and displayContent. Now it seems the Ajax response is indeed only the code of the body, but the response still gets a 404 error. Anyone have any experience with this? Link to comment Share on other sites More sharing options...
vivek tripathi Posted August 2, 2011 Share Posted August 2, 2011 Hi Muller you can use following jquery code block to get desire content from ajax response excluding header and footer $.ajax({ type:"POST", url: "category.php", data:"id="+id , success: function(data){ //create jquery object from the response html var $response=$(data); //query the jq object for the values var oneval = $response.filter('#center_column').text(); // you can use oneval value it simply return value inside div id centre_column excluding header footer } }); Link to comment Share on other sites More sharing options...
Muller Posted August 3, 2011 Author Share Posted August 3, 2011 I think it's more efficient to change the category.php to return only the body, instead of getting everything and filtering the center column div. What I did was (as I wrote in my last post) override CategoryController::run and comment out display header and display footer. My Ajax query kept getting 404s so I changed the part about 404 messages in the CategoryController::process function. It was either that or accepting the 404 messages and using the Ajax complete function instead of success function, but I preferred editing the page itself Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now