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


What is wrong with this code because the submit button is not working?

这是代码。这是我创建的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 (){}
    });
});

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

 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 (){}
  });
you are not concatenating query string in the correct format.
Please try below code.
jQuery.ajax({
    url: "http://localhost/success-page",
    type: "POST",
    data: 'name=' +name+'&email='+email+'&phone='+phone+'&content='+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 (){}
    });
});
I hope this will helps you