weixin_33695450 2011-09-20 14:15 采纳率: 0%
浏览 8

从javascript到PHP的值

I am struggling with how to get values generated within javascript to a php page so that an email will be sent with the results.

function sendmemail(){

        var data = 'result=' + result.val();

$.ajax({

            url: "process.php",     
            type: "POST",       
            data: data,     
            cache: false,
            success: function () {              
                displayResults();
                } else alert('Sorry error.');               
            });     
        }
  • 写回答

5条回答 默认 最新

  • weixin_33749131 2011-09-20 14:17
    关注

    That else part is a syntax error, you can't add an else clause in that way.

    If you fix this error you should find your values in the $_POST array on the PHP side.

    You can also use a Javascript object to pass the values:

    var data = { result: result.val() }
    

    which is more readable.

    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器