JavaScript/Php strange mishap, data became a key? -


i using code:

    javascript: (function () {        var jscode = document.createelement('script');        jscode.setattribute('src', '//ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js');                         document.body.appendchild(jscode);     var stuid = prompt("please provide student id");     $.ajax({         url: "data.php",         data: stuid,         success: function(response) {             console.log(response);         }     });  }());   

and var_dump came strange. var_dumped request , got..

 array(1) {   [1]=>   string(0) "" } 

why did become associative array's key? how can avoid it?

i sorry if sounds stupid question, new.

this problem:

 data: stuid, 

the data variable needs key - value pairs, need like:

 data: { "id": stuid }, 

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

qt - Errors in generated MOC files for QT5 from cmake -