jquery - getting response from a php script -


so created html site multiple forms, using jquery dialog ui display , jquery form plugin ajax submission.

form looks this:

<form id="login_form" action="admin.php" method="post">     username: <input type="text" name="username" id="username"/><br/>     password: <input type="password" name="password" id="password"/> </form> 

...the form options this:

$('#login_form').dialog({     buttons:{         "login": function(){         var options = {          success: function(data){             alert(data);                 $(this).dialog("close");                 $('#news_form').dialog("open");             },             timeout: 3000,             fail: function(data){                 alert('fail');             },             clearform: true         };           // bind form using 'ajaxform'          $('#news_form').ajaxsubmit(options);          },         "exit": function(){             $(this).dialog("close");         }     } }); 

...and php file simple:

<?php     $data = 'herro!';     echo $data; ?> 

problem on success form returns html page source of submit , not 'herro!' anticipated. doing wrong?

both admin.html , admin.php files in same dir.

also web run locally via xampp, tried put on web server no improvements.

final edit: problem in fact because calling different form object in dom submit data, form doesn't have action property set. quick solution.

change $('#news_form').ajaxsubmit(options); $('#login_form').ajaxsubmit(options);


Comments