post value through ajax of uploaded file in php -


we trying post 1 data string through ajax here how looks

// if captcha correctly entered!                            if ($resp->is_valid) {  echo $tmpname; ?>                          <script type="text/javascript">  $(document).ready(function(){     alert("in ready");         var name = "<?php echo $_post['name']; ?>";          var email = "<?php echo $_post['email']; ?>";         var state = "<?php echo $_post['state']; ?>";         var contact = "<?php echo $_post['phone']; ?>";          var message = "<?php echo strtr($_post['message'], array("\r\n" => '<br />', "\r" => '<br />', "\n" => '<br />')); ?>";           // returns successful data submission message when entered information stored in database.        var datastring = 'name1='+ name + '&email1='+ email + '&state1='+ state + '&contact1='+ contact + '&message1='+ message +'&tmpname1='+ "<?php echo $tmpname ?>" +'&filetype1='+ "<?php echo $filetype ?>" +'&filename1='+ "<?php echo $filename ?>";           alert(datastring);          if(name==''||email==''||contact=='')         {             alert("please fill fields");         }         else         {         // ajax code submit form.             $.ajax({                 type: "post",                 url: "mailer.php",                 data: datastring,                 cache: false,                 success: function(result){                     alert(result);                 }             });         }         return false;  }); 

when trying value of tmpname1 can not rest name1 can value. can suggest on issue?

thank you!

you use different approach naming values.

var dvals = {};  dvals = {     name1: name,     email1: email,     ... }; 

personally don't , i'm not 100% sure why, know use in code.

var dvals = {}; dvals['name1'] = name; dvals['email1'] = email ... 

you can use name each 1 sure , replace datastring in ajax code dvals. not sure why datastring incorrect, know stopped using because of random problems kept running made me feel unreliable. why switched using methods above.


Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -