When javascript-ajax transfers data and jumps to the past, it finds that the data is empty.

Source: Internet
Author: User
This is the ajax code {code ...} this is the code controlled by the ci framework {code ...} no id value exists in echo, and no reason can be found .... is it because the data is no longer in the past? I can use another deleted ajax function without redirecting to the Controller. What if I want to transfer data to the Controller and redirect ?... This is the ajax code.

$(".glyphicon-pencil").click(function(){                var id = $(this).attr('rel');        var URL = "
  ";        $.ajax({            type:'post',            url:URL,            data:{"id" : id},            success:function(msg){                window.location.href="
  ";            }        });            });

This is the code controlled by the ci framework.

public function update(){        $id = $this->input->post('id');        echo "$id";        exit;        $thisdata = $this->News_model->getContent($id);        $data['update'] = $this->News_model->getall();        $data['id'] = $thisdata['id'];        $data['title'] = $thisdata['title'];        $data['content'] = $thisdata['content'];        $data['children'] = $thisdata['children'];        $this->load->view('admin/update',$data);    }

No id value exists in echo, and no reason can be found ....
Is it because the data is no longer in the past? I can use another deleted ajax without redirecting to the Controller.
What should I do if I want to transfer data to the Controller and redirect it?
I am confused about this problem when I got started ..

Reply content:

This is the ajax code.

$(".glyphicon-pencil").click(function(){                var id = $(this).attr('rel');        var URL = "
  ";        $.ajax({            type:'post',            url:URL,            data:{"id" : id},            success:function(msg){                window.location.href="
  ";            }        });            });

This is the code controlled by the ci framework.

public function update(){        $id = $this->input->post('id');        echo "$id";        exit;        $thisdata = $this->News_model->getContent($id);        $data['update'] = $this->News_model->getall();        $data['id'] = $thisdata['id'];        $data['title'] = $thisdata['title'];        $data['content'] = $thisdata['content'];        $data['children'] = $thisdata['children'];        $this->load->view('admin/update',$data);    }

No id value exists in echo, and no reason can be found ....
Is it because the data is no longer in the past? I can use another deleted ajax without redirecting to the Controller.
What should I do if I want to transfer data to the Controller and redirect it?
I am confused about this problem when I got started ..

You are not using the returned data, and you will jump directly toupdatePage now

You putwindow.location.href=" ";This sentence is changedalert(msg)Try

Select network debugging for F12 ~~

You have never used your templates and frameworks ~~
" "Can I parse it into a correct url? Is the value of the id passed by the front end blank? Network can be seen

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.