Welcome Guest, Not a member yet? Register   Sign In
Jquery ajax request works in some pages and in others it doesnt
#11

[eluser]Matalina[/eluser]
Okay so where is data.html?

When you move from the site the location is going to change.
#12

[eluser]iceuser[/eluser]
[quote author="Matalina" date="1340918445"]Okay so where is data.html?

When you move from the site the location is going to change.[/quote]

it is supposed to be the json encoded array i should get from the ajax request like:

Code:
$data = array(
            'html' => $this->html,
            'error' => $this->error,
        );

        header('Content-type: application/json');

        echo json_encode($data);

this code is on the bottom of the function called via ajax
#13

[eluser]Matalina[/eluser]
redacted
#14

[eluser]iceuser[/eluser]
[quote author="Matalina" date="1340918968"]What is this suppose to do?

Code:
success: function(data)
            {
                alert( "SUCCESS" );
                $(".page").html(data.html);
            }

What it looks like to me is that it is suppose to print "data.html" to the .page object in your DOM.[/quote]

when the ajax request is completed successfully, it simply adds the comments that it fetches from the ajax query into the .page container... i don't see anything wrong here...
#15

[eluser]Matalina[/eluser]
It took me a while to get what was going on lol... you responded while I redacted lol.
#16

[eluser]Matalina[/eluser]
whats your controller look like?
#17

[eluser]iceuser[/eluser]
[quote author="Matalina" date="1340919131"]whats your controller look like?[/quote]

other than i have deleted everything except the above code just to be sure it works... but it still wont work on firefox and chrome on mac machine...

it looks like

Code:
<?php
class comment extends CI_Controller
{

private $error = false;
private $html = '';


public function __construct(){
     parent::__construct();
}

function getComments(){
   $data = array(
    'html' => $this->html,
    'error'    => $this->error
   );
  
   header('Content-type: application/json');
  
   echo json_encode($data);
}

}
#18

[eluser]Matalina[/eluser]
My gut says it's your crsf protection. Turn it off to test if it'll go thru. If it does then you know that's your problem.

If it doesn't then it something else;
#19

[eluser]iceuser[/eluser]
[quote author="Matalina" date="1340919508"]My gut says it's your crsf protection. Turn it off to test if it'll go thru. If it does then you know that's your problem.

If it doesn't then it something else;[/quote]

here is something interesting...

1) if i remove all the variables that i pass to the controller it works
2) if i change POST to GET it works
3) why is this happening to me? LOL!!


EDIT: i found another interesting thing... it is that if a variable that i pass looks like "AEs8taCReh73165a7fa1ac001486b67e69d9a7c8cb1c0de277ypgY7" it seems to create the problem... so my guess is that it cant handle that big variable value? weird
#20

[eluser]Matalina[/eluser]
1. Do you have crsf protection enabled?
2. I could be wrong, but crsf protection doesn't work with get statements as get's are typically in the url (though I could be wrong)

Are you posting a form? or just using post as an ajax call to do something?




Theme © iAndrew 2016 - Forum software by © MyBB