开发者

Jquery - Access to the postanswer on every post

开发者 https://www.devze.com 2023-01-15 17:23 出处:网络
is it possible to get access to the postanswer? For exmaple: This is my post $.post(\'test.php\', {mx: \'alpha_one\', ft: \'get_it\', \'values[0]\':\'25\', \'values[1]\':\'10\'},

is it possible to get access to the postanswer?

For exmaple:

This is my post

$.post('test.php', {mx: 'alpha_one', ft: 'get_it', 'values[0]':'25', 'values[1]':'10'},
function(data_lv)
{

.....

}, 'json'); 

and this is the answer

{"bibo":"3733c0f973590e579b78f1473fb96fbe","success":true,"data":{"1":"bernd","52":"blub","135":"blib","133":"Cleack","115":"Cl2"},"msg":"bluub"}

i can check every poststop with

$(window).ajaxStop(function(data_lv)
{


}, 'json'); 

but how can i check the bibo?

$(window).ajaxStop(function(data_lv)
{

   alert(data_lv.bibo); // <---- DONT WORK

}, 'json'); 

Hope开发者_如何转开发 someone can help me.

Thanks in advance! Peter


If i get it right, you are doing a post to a php file, and then want to check if it was executed succesfully.

what I do i: execute the php function, and encapsulate it with a try catch.

if it worked, return the data, else retur a "false". then in my post I do:

$.post('ajax/test.html', function(data) {
  if(data != "false"){
   //execute your succes thingys
  }
});

you can read more about the post function and handling the succes here

0

精彩评论

暂无评论...
验证码 换一张
取 消