PHP - AJAX Process HTTP requests -


i have form x number of fields. when submitted, want to;

  1. get input data, $var = $_post['input']
  2. validate input, (!empty($var) && is_numeric($var))
  3. stick in array, array_push($myarray, $var)
  4. generate urls, $url.=$var
  5. process url's without leaving page

1 - 4 done in php

simply, im not familiar ajax. been decade since ive touched javascript. im not sure if should using javascript whole process. however, prefer php validate, ajax http requests. sample code/sites available passes php var's/array ajax handle http requests?

you'll want use kind of format pass data server client. recommend json. php has a built-in function encode array it, , javascript parses natively.

as ajax part itself, recommend using framework jquery. makes way simpler, , don't have deal different browsers yourself.

$.ajax({   url: "yourpage.php",   success: function(data){     alert(data);   } }); 

Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -