php - sending and recieving an ajax call -


i looked ages prevent being duplicate can't seem find answer.

on previous jquery page used following ajax call:

var daynum1 = $(this).text(); var month1 = $('.ui-datepicker-month').text(); var year1 = $('.ui-datepicker-year').text(); var mydate = daynum1 + " " + month1 + " " + year1; $('#headingcontent').html(mydate);  $.ajax({   url: "events.php",   type: "post",   data: { mydate: mydate },   datatype: "html",   success: function(html) {     $("#eventcontent").empty();       $("#eventcontent").append(html);   } }); 

this worked absolutely perfectly. events.php able pick variable using:

if(isset($_post['mydate'])) 

however i've come use different ajax call send data different page:

var titleevent = $("#dropdowntextbox").val();  $.ajax({   url: "editevents2.php",   cache: false,   data: { titleevent: titleevent },   datatype: "html",   success: function(html) {     $("#editeventspopup").empty();       $("#editeventspopup").append(html);   } }); 

however can't life in me working! page should receive call has set:

if(isset($_post['titleevent'])) {   $title = $_post['titleevent'];   echo "hooray found it"; } else {   echo "hello"; } 

every single time, hello echoed. i've tried add , alert print data me on success i'm quite new stopped working altogether.

my guess (which doesn't mean much) because variable .val , not .html down the data type. i'm not sure else can set to.

thanks help.

based on edit seems problem type. default type used jquery's $.ajax() method get. in order use post, need specify that:

$.ajax({   url: "editevents2.php",   type: "post",  // specify type post   cache: false,   data: { titleevent: titleevent },   datatype: "html",   success: function(html) {     $("#editeventspopup").empty();       $("#editeventspopup").append(html);   } }); 

Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -