javascript - Returning values from a PHP script for an AJAX method: What am I doing wrong here? -


from i've read on internet, way of returning html, json, etc., php script echoing it. can't work, however.

my js

        jquery('#new-member').submit(             function()             {                 var formurl = jquery(this).attr('action');                 var formmethod = jquery(this).attr('method');                 var postdata = jquery(this).serializearray();                 console.log(postdata); // test                 jquery.ajax(                     {                         url: formurl,                         type: formmethod,                         datatype: 'json',                         data: postdata,                         success: function(retmsg)                         {                             alert(retmsg); // test                         },                          error: function()                         {                             alert("error"); // test                         }                     }                 );                 return false;             }                ); 

and i've verified correctly calling php script, test

<?php    echo "yo, dawg."; ?> 

but open "yo, dawg." in new page. expected behavior alert message on same page on. missing here?


Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -