这段代码有什么问题,因为提交按钮不起作用?

时间:2016-07-28 08:13:34

标签: php jquery ajax wordpress

这是代码。它是我创建的wordpress页面。两个页面都在同一个文件夹中。我将数据从leadgen.php发送到page-success.php

jQuery.ajax({
    url: "http://localhost/success-page",
    type: "POST",
    data: 'name=' +name+'&email='+email+'&phone='+phone+'&content='+'&city='city+'&date='+date+'&event_type='+event_type+'&service='+service+'&guests='+guests+'&budget='+budget+'&locality='+locality+'&food_type='+food_type+'&venue_type='+venue_type+'&photography_type='+photography_type;

    success:function(data){
    document.location.href = 'http://localhost/success-page/';
    },
    error:function (){}
    });
});

2 个答案:

答案 0 :(得分:0)

发布这样的数据,不要使用查询字符串。

 jQuery.ajax({
   url: "http://localhost/success-page",
   type: "POST",
   data: {
      Name: name,
      Email: email
      // more data you want to post....
    },
   success:function(data){
       document.location.href = 'http://localhost/success-page/';
    },
  error:function (){}
  });

答案 1 :(得分:0)

Allow