javascript - Can not seem to pass more than one variable with jquery to mysql -
I have seen many examples and I used jquery to get mysql to hang in passing more than one variable Can not seem to Here's my situation:
I have 2 cascading dropdowns (they work very well by using jquery to update the second drop down based on the first drop down.) < / P>
The first drop down jazzery update is selected from the second drop down and sends the customer ID to a PHP script which creates a new record in the TbilisiVoice table (this is not a big problem too.)
B. The second is determined drop down, could I update instid with the value of my need to invoice PHP script that I record. (This is the part that does not work)
If I only put Instvo and manually the invoice number where all the sections of the query work fine, if I say that all the records where the required form I have to know what I am doing wrong or what is missing.
I will try to post the code here
jquery code
$ (document) .ready ARTR ('value'); Var test = $ ("(" "test") (function () ($ {"select # cust"). "()". () ". ()". (""); $ ("# Id"). Val (); $ ("# inst") .HTML (""); if (cust_id.length & gt; 0) {$ .ajax ({Type: "post", url: "fetch_inst.php", data: "$ String_id" = " (Test == 0) {$ .ajax ({type: "24" & quot;);}, success: function (html) {$ ("# inst"). Html (html);}}); "POS T", URL: "wo_start.php", data: "cust_id =" + cust_id, cache: wrong, preceded: function () {}, success: function (html) {$ ("# invoice"). (Html); $ ("# test") value (1). Var inum = $ ("# inv"). Val (); $ ("# invnum"). Val (day + "-" + inum); }});}}}); 'Value';; Var custid = $ ("Select # Customer Options: Selected" $ ("Choose # Inst").) ;attr ('value'); Var invid = # ("#inv"). Val () if (inst_id.length & gt; 0) {$ .ajax ({type: "POST", url: "wo_start.php)", data: {inst_id: inst_id,} cache: wrong, preceded: function ( ) {}, Success: function () {}})}}}); }); I have tried to use the data: {inst_id: inst_id, custid: custid, invid: invid,} (there is no update in the table like this)
I also tried the data: "inst_id =" + inst_id + "& custid =" + custid + "and invid =" + invid, (This also gives no result.)
Anyone please look at this jquery and see I am making a simple error?
Try this format:
Data: {inst_id: Inst_id, custid: custid, invid: invid}, You can post a JSON object on the server, as long as you can serial it and then type the data to the server .
You first need to define your JSON object:
var postData = {inst_id: inst_id, custid: custid, invid: invid}; Then update your AJAX to use the sequential version of that object and let the server know the data type:
$. Ajax ({type: post}, url: "fetch_inst.php", data: JSON.stringify (postData), contentType: "application / json", .. continue the rest of your Ajax ....
Comments
Post a Comment