html - Unable to fill input value with PHP variable -


i have 2 files, landing.php , test.php. landing.php has form submitted via ajax using post method test.php. if ajax call successful, browser loads test.php, @ point having issue. cannot figure out doing wrong in attempts display value of post data sent test.php.

the following ajax call landing.php. reasonably sure working correctly having looked @ post data in firebug.

$('#searchform').submit(function(e) {     e.preventdefault();     var data1 = $('#checkboxdiv input').serialize() + '&' + 'barcodeid=' + $('#barcodeid').val();     $.ajax({         url: 'test.php',         data: data1,         type: 'post',         success: function() {             window.location.href = "test.php";         }     });   });   

here contents of test.php.

<?php  $bar = $_post['barcodeid'];  echo "<html>"; echo "<body>"; echo "<p>*" . $bar . "*</p>"; echo "</body>"; echo "</html>"; ?> 

if take asteriks out of line <p> test.php, presented blank screen when arrived @ test.php in browser. them there, however, presented "**" on screen. confusing part is, however, if include

echo $bar;

in test.php, see value of $bar (00-00102 - should be) in firebug's response tab on post data viewer.

after research, read post method of choice when not want display query strings in url bar, method use when have large amount of data send (which case me, it'll end being around 5 6 hundred characters when said , done). i've looked @ other stackoverflow posts , articles, attempted replicate recommended, , still cannot right.

am doing wrong or attempting use these methods in way in not intended used?

don't change window location in success of ajax call. call posting data test.php , getting response there. redirecting page blank post results in asterisks.

if want display results test.php change $.ajax call following:

$.ajax({     url: 'test.php',     data: data1,     type: 'post',     success: function(response) {         $('html').replacewith(response);     } }); 

or if want change page, forget ajax , post form test.php


Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -