Welcome Guest, Not a member yet? Register   Sign In
Load a view
#1

[eluser]GrootBaas[/eluser]
Hi there,

Any help would be very much appreciated ...

In my controller I load a form like this ...

Code:
function index() {
        
        $rules = $this->_load_logs_rules ();
        $this->validation->set_rules ( $rules );
        $fields = $this->_load_logs_fields ();
        $this->validation->set_fields ( $fields );

                $this->layout->buildPage($this->config->item('log_sum_view'), $data);
                 }

From within this form, I use AJAX like this ...

Code:
var contract_no = $('.trSelected td:nth-child(2) div').text();
                
                           $.ajax({
                               url: "<?=base_url()?>logs/update_logs",
                            global: false,
                              type: "POST",
                             async: true,
                          dataType: "html",
                              data: "con_num="+ contract_no
                });

In the Update logs function within the controller, I call another form like this ...

Code:
function update_logs() {
        $options = null;
        $contract_no = $this->input->post ( 'con_num' );
        
        log_message('debug','LOGS - Selected contract '.$contract_no);
        
        $this->load->view('default/content/log/log_detail');
        return TRUE;

The new from is not loaded (nothing happens), but in my message logs, it says that ...

Quote:DEBUG - 2008-10-16 18:38:40 --> File loaded: C:/WebAus/ifleetiii/system/application/views/default/content/log/log_detail.php


Could somebody please help me?
#2

[eluser]Dready[/eluser]
Hello,

first of all, for debugging things like ajax, I suggest you use the "httpfox" firefox addon, it's simple and really cool.

Now, in your ajax call, you don't do nothing with the html the server returns, I suggest you add the success option, something like :

Code:
$.ajax({
                               url: "<?=base_url()?>logs/update_logs",
                            global: false,
                              type: "POST",
                             async: true,
                          dataType: "html",
                              data: "con_num="+ contract_no,
                           success: function (data,textstatus) {
                                       alert(data);
                                    }
                });

Does it work better ?
#3

[eluser]GrootBaas[/eluser]
Hi, thanks for your suggestion.

The AJAX is working fine. No problem there...

I think my issue is whitin the form...

Do i need something like

Code:
<?=form_open('quotes/submit_order');?>

in my forms? In both of them?
#4

[eluser]GrootBaas[/eluser]
Hi Guys,

I am still very much stuck at this point.

Could anybody please spear some time for me?

Regards,
Me.
#5

[eluser]GrootBaas[/eluser]
It seems to work with a button.

Does that mean that AJAX does not submit the form?
#6

[eluser]GrootBaas[/eluser]
How can I do the same with my ajax call ...

Code:
var contract_no = $('.trSelected td:nth-child(2) div').text();
                
                $.ajax({
                               url: "<?=base_url()?>logs/update_logs",
                            global: false,
                              type: "POST",
                             async: true,
                          dataType: "html",
                              data: "con_num="+ contract_no                      
                });

as what I do with this button ...

Code:
<?=form_submit(array('id' => 'button', 'name' =>'btn_order', 'value' => 'test')); ?>

There must be a difference, i just dont know ...
#7

[eluser]GrootBaas[/eluser]
Hey guys,

I solved it ...

All i had to do was to add this in my form HTML ...
Code:
<form name="get_password" method="post" action="logs/update_logs">
and in my JavaScript, i had to submit the form

Code:
document.get_password.submit();

The rest (Ajax and CI) stayed the same.

Can anybody explain to me why a web form need to be explicitly submitted.
#8

[eluser]narkaT[/eluser]
you haven't solved the problem, you just worked around it Smile


your're probably misunderstanding the concept of AJAX.

like Dready said, when the ajax-request is complete you'll
have to do something with the result in order to see any changes.

ps: Most frameworks prefer an object instead of a parameter-string when dealing with ajax:
Quote:$.ajax({
url: "<?=base_url()?>logs/update_logs",
global: false,
type: "POST",
async: true,
dataType: "html",
data: {
con_num: contract_no
}
});




Theme © iAndrew 2016 - Forum software by © MyBB