The post->success->data variable is empty
I tried sending some data like so:
<form action="http://www.someurl.com/something.php" id="login">
<input type="textbox" id="UserName" value="user">
<input type="textbox" id="Password" value="password">
<input type="submit" value="submit">
</form>
<div id="result"></div>
<script type="text/javascript">
$('form#login').submit(function() {
$.post($('form#login').attr('action'), $('form#login').ser开发者_如何学Cialize(), function(data) {
$('#result').html(data+'222')
});
return false;
});
</script>
Now, the value of #result div change to 222... that is: the post was successful but for some reason there is no data, and when I go directly to something.php and post manually, it does bring back data (am I mistaken or does the post(success(data)) variable returns the whole page returned after you post something? if so, how could it be?)
Thank you very much for your help
what is your request type?
Try this...
$('form#login').submit(function() {
$.post($('form#login').attr('action'), $('form#login').serialize(), function(data) {
$('#result').html(data.success+'222')
});
return false;
},'json');
Have your script out put this as a test: {"success" : "some data" }
精彩评论