jquery - ajax and codeigniter duplicating header -


I have a strange problem that I am unable to track down. I am using Codeigniter and Jquery to create an AJAX search feature.

Everything is working fine and the correct data has been returned from my model, but when I load the view from the controller, in response.

I have tried an empty scene to load and even then the header of the page has been included.

My Javascript function is like

  function filter (id) {var str = "test"; Var series = {}; // init array data ['id'] = id; Var url = "/ baseurl / controller / filename"; $ ('# Result'). Load (url, data, function (str) {}); }  

Since then, I get results from the model from within my controller. I only load the view

  $ this-> load-> View ("Results", $ data);  

> P>

  & lt; / Head & gt; & Lt; Body & gt; & Lt; Div id = "container" & gt; & Lt; Div id = "wrapper" & gt; & Lt; Div id = "header" & gt; & Lt; / Div & gt; & Lt ;! - End header - & gt; & Lt ;! - Menu - & gt; & Lt; Div id = "menu" & gt; & Lt; Ul & gt; & Lt; Li & gt; & Lt; A href = "#" & gt; Home & lt; / A & gt; & Lt; / Li & gt; & Lt; Li & gt; & Lt; A href = "#" & gt; About us & lt; / A & gt; & Lt; / Li & gt; & Lt; Li & gt; & Lt; A href = "#" & gt; Testimonials & lt; / A & gt; & Lt; / Li & gt; & Lt; Li class = "last" & gt; & Lt; A href = "#" & gt; Link & lt; / A & gt; & Lt; / Li & gt; & Lt; / Ul & gt; & Lt; Div id = "sub-menu" & gt; & Lt; Ul & gt; & Lt; Li & gt; & Lt; A href = "#" & gt; Profile & lt; / A & gt; & Lt; / Li & gt; & Lt; Li class = "last" & gt; & Lt; A href = "#" & gt; Privacy & lt; / A & gt; & Lt; / Li & gt; & Lt; / Ul & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt ;! - End Menu - & gt;  

Test Ajax

  & lt; / Div & gt; & Lt ;! - & House - & gt;  

As shown in the results, the information inside the div is the content that is coming from the scene but all the above information is additional information. This is the rest of the page above the division that I am trying to update

Kind of thanks Ben

compression? If you are trying to close it with CodeIgniter config.php

Edit:

Option 1: If you are receiving an AJAX call, Can check. Try creating this assistant:

  & lt ;? Php if (! Defined ('BASEPATH')) Exit ('no direct script entry is allowed'); Function is_ajax () {return provider ($ _ server ['HTTP_X_REQUESTED_WITH']) & amp; Amp; $ _SERVER ['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest'; }? & Gt;  

Then try to do this in your method:

  if (is_ajax ()) {// do your work} and {$ the-> Load - & gt; View ('your_view'); }  

Hope this will solve ...

Option 2

You just echo and html string eg. 'Your data' and no load view


Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

php - Multiple Select with Explode: only returns the word "Array" -

php - jQuery AJAX Post not working -