php - Why is isset($_POST['submit1']) equal to FALSE? -


this follow-up of question posted few hours ago (php post method apparently not working). code still not should, code , question have changed prefer post new question (also considering questions seem read after have been posted). i’ll try close earlier question (still new here).

on question then: why is, in code given below, isset($_post['submit1']) equal false when tested? in other words, why $_post['submit1'] equal null? believe that’s need know.

here code, consists of 2 files. file ‘form.php’ (copied literally jquery-site: http://www.visualjquery.net/category/ajax/jquery.post , see last example) contains following code:

<!doctype html> <html lang="en">  <head> <meta charset="utf-8"> <title>jquery.post demo</title>   <script src="http://code.jquery.com/jquery-1.9.1.js"></script> </head>  <body>  <form action="formprocessing.php" name="formpje" id="searchform"> <input type="text" name="s" placeholder="search..." /> <input type="submit" value="search" name="submit1" /> </form>  <!-- result of search rendered inside div --> <div id="result"></div>  <script>  /* attach submit handler form */ $("#searchform").submit(function(event) {  /* stop form submitting */ event.preventdefault();  /* values elements on page: */ var $form = $( ), term = $form.find( 'input[name="s"]' ).val(), url = $form.attr( 'action' );  /* send data using post */ var posting = $.post(url,{s: term},'json');  /* put results in div */ posting.done(function( data ) { var content1 = $( data ).find( '#content' ); contentstring = json.stringify(content1); $( "#result" ).empty().append( contentstring );  });   });  </script> </body> </html> 

and file ‘formprocessing.php’ contains following (this includes isset-test):

<!doctype html>  <?php if(isset($_post['submit1'])) { echo ( json_encode(array("content" => $invoer)) );  } ?> 

thanks!

because never set submit1 part of data object you're passing $.post():

var posting = $.post(url,{s: term},'json'); 

$.post() not automatically pass through of form values; sends specify in second argument. thing set in $_post 's' key.


Comments

Popular posts from this blog

java - JavaFX 2 slider labelFormatter not being used -

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -