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

What Are The Best Universities In The World?

Hard vs. Soft Water: What's The Difference?

java - Solr query version issue: Invalid version or the data in not in 'javabin' format -