Welcome Guest, Not a member yet? Register   Sign In
ajax, jquery problem
#11

[eluser]GrahamDj28[/eluser]
You call the getCookie function to get the token value that has been set by CI.
Then you add the token to your data set that you are posting. Just as you have added the variable name, you add an extra variable containing the token.

Code:
$('#getdata').click(function(){
    var name= "johns";
    var my_csrf_token = getCookie(cookie_name);
    $.ajax({
        url: '<?php base_url() ?>message/sam',
        type: 'POST',
        dataType: 'json',
        data: {  
            name: name,
            csrf_token: my_csrf_token // The key name must match the name in your CI config file
        },
        success: function(output_string){
            $('#result_table').append(output_string);
        } // End of success function of ajax form
    }); // End of ajax call
});

I think you should be able too figure this out now
#12

[eluser]seegan[/eluser]
[quote author="GrahamDj28" date="1356884140"]You call the getCookie function to get the token value that has been set by CI.
Then you add the token to your data set that you are posting. Just as you have added the variable name, you add an extra variable containing the token.

Code:
$('#getdata').click(function(){
    var name= "johns";
    var my_csrf_token = getCookie(cookie_name);
    $.ajax({
        url: '<?php base_url() ?>message/sam',
        type: 'POST',
        dataType: 'json',
        data: {  
            name: name,
            csrf_token: my_csrf_token // The key name must match the name in your CI config file
        },
        success: function(output_string){
            $('#result_table').append(output_string);
        } // End of success function of ajax form
    }); // End of ajax call
});

I think you should be able too figure this out now[/quote]

Woow thankyou man my problem solved..
Thankyou very much..
#13

[eluser]GrahamDj28[/eluser]
You are welcome!
#14

[eluser]nishant1234[/eluser]
thanks to all of you guys
#15

[eluser]nishant1234[/eluser]
go to stack overflow.com its good one...




Theme © iAndrew 2016 - Forum software by © MyBB