小编B_C*_*erA的帖子

CodeIgniter控制器 - JSON - AJAX

我正在尝试通过AJAX发送带有CodeIgniter的表单构建,并尝试使用JSON获取响应.但是,当我打开我的开发人员选项卡时,我只看到响应(我甚至不确定,如果它实际上是响应,因为它显示了两个json数据).

它显示的只是加载微调器,然后消失.

代码已在没有AJAX的情况下进行了测试,并且可以正常运行,因此PHP中不会出现错误.

这是我的重置密码的控制器:

<?php

Class Users extends CI_Controller {

    public function forgot_pass()
    {

    if(!$this->input->post('to_email'))
    {
    exit("No data");
    }


    $this->load->model('user');
    $email = $this->input->post('to_email');
    $email_addr = $this->user->get_email_address($email);


    if(empty($email_addr))
    {
    echo json_encode(array('pls'=>0, 'msg' => "E-mail address was not found. Try  again"));
    }

    $this->load->helper('string');
    $new_password = random_string('alnum', 8);
    $this->load->library('phpass'); 

    $update_password = array( 'password' => $this->phpass->hash($new_password));
    $update_password = $this->user->update_password($email, $update_password);

    $this->load->library('email');

    $config['newline'] = '\r\n';
    $this->email->initialize($config);

    $this->email->from('your@example.com', 'Your Name');
    $this->email->to($email);  
    $this->email->subject('New password');
    $this->email->message("Hey, " .$email_addr['name']. ". Your new password is: " .$new_password); 

    if($this->email->send())
    {
    echo …
Run Code Online (Sandbox Code Playgroud)

php ajax jquery json codeigniter

4
推荐指数
1
解决办法
2万
查看次数

使用画布元素使用javascript调整图像大小

我很难理解如何使用canvasJavaScript 中的元素。

我正在实现一个调整大小功能,用户可以在其中调整lightbox. 该lightbox会推出之后预览图像被点击。在lightbox元素内部,除了图像本身,还有宽度和高度两个输入字段。

目标是以base64格式生成原始图像的副本,并将其连同给定的宽度和高度作为查询参数发送到服务器,并让服务器端执行调整大小操作(我在后端使用 PHP)甚至更好的是,让 JavaScript 在前端进行调整大小操作,并返回新的调整大小的图像,准备通过ajax.

问题是我不完全知道如何处理动态创建的canvas元素以及如何使用它在前端调整我的图像大小。

下面是我迄今为止尝试过的结果不佳的方法:

index.html (省略了基本的 HTML 元素和灯箱效果)

<!-- input fields for width and height -->
<div class="container">
    <div class="form-inline">
        <div class="form-group">
            <input type="number" class="form-control" id="width" placeholder="px">
        </div>
        <div class="form-group">
            <input type="number" class="form-control" id="height" placeholder="px">
        </div>
        <button id="resize" type="button" class="btn btn-primary">Resize</button>
    </div>
</div>

<!-- preview image -->
<div class="container">
    <img src="img/img1.jpg" alt="" class="img-responsive" id="preview">
</div>

<script type="text/javascript">
    button = document.getElementById("resize"); …
Run Code Online (Sandbox Code Playgroud)

javascript canvas image html5-canvas

2
推荐指数
1
解决办法
245
查看次数

标签 统计

ajax ×1

canvas ×1

codeigniter ×1

html5-canvas ×1

image ×1

javascript ×1

jquery ×1

json ×1

php ×1