Cannot send jQuery ajax() request to php -
I have trouble using the AJAX () function. I have an HTML file with a form and it contains JavaScript code Is a section of:
& lt; Script & gt; $ (Document) .ready (function () {$ ("form"). Submit (function () {var url = "xxx.php /"; var param = $ ("# streetInput"). Serialize () + " Serialize (); htmlobj = $ .ajax ({url: url); & amp; , Data: Ultimate, Type: 'GET', Data Type: 'JSON', Success: Function (Output) {// Parsing Data Here}, Error: Function () {}});});}); & Lt; / Script & gt;
I should create a URL, pointing to a specific php file with the GET method. However, I do not know how to recover the parameter sent through the URL in the xxx.php file. I do not know how to debug, I just type
& lt ;? Php echo $ _GET ("streetInput"); Echo $ _GET ("cityInput"); ...... $ xml = simplexml_load_file ($ url); ? & Gt;
But it was not working. Can somebody help me out? I want to give xxx.php to the three parameters through the URL, then print those elements
In your JS code:
& lt; Script & gt; $ (Document) .ready (function () {$ ("form"). Submit (function () {var url = "xxx.php"} var param = $ ("# streetInput"). Serialize () + "& ;;; Param + = $ ("# cityInput"). Serialize () + "& amp;" Ultimate + = $ ("# stateInput"). Serialize (); $ .ajax ({url: url, data) : Ultimate, Type: 'GET'});});}); & Lt; / Script & gt;
Or, if you have only these field forms, then use it:
& lt; Script & gt; $ (Document) .ready (function () {$ ("form"). Submit (function () {var url = "xxx.php"} var param = $ (this) .serializeArray (); // & lt; - or, $ .jax ({url: url, data: ultimate, type: 'GET'});});} can also be used for .erialize (); & Lt; / Script & gt;