weixin_33728268 2012-03-23 09:16 采纳率: 0%
浏览 20

为什么对象总是空的?

i have a little problem with my Ajax calls. Maybe i do not have the right approach here or i did not understand it correctly.

Here is what i do: i create a new object once and set a value with the function set_value for a variable defined in the __constructor in createobj.php

$obj->set_value(10);

The object is created in class_obj.php. and the value is 10.

Then i make an ajaxcall with jquery and json:

$jq.getJSON(ajaxcall.php? + options, function(data) {

But when i call the obj in ajaxcall.php again it is empty? I do not understand why, so i appreciate any tipps, tutorials ebooks and your help for better understanding.

How can i achieve it, that i can access the same object created in createobj.php in ajaxcall.php with all values, setting new ones etc.? So a "global" object. Or do i have to send the obj with the ajaxcall?

Thank you for bringing light into the dark ;)

  • 写回答

1条回答 默认 最新

  • 7*4 2012-03-23 09:31
    关注

    Sounds like you're expecting the value to stay as it was when you execute another script (the AJAX script), which won't work, they will act as completely different scripts, so no information will be passed between them.

    You'd either have to set the value to a SESSION, or save it in some way (e.g. to a database) and then "load" the values from an ID set in a SESSION variable.

    评论

报告相同问题?

悬赏问题

  • ¥15 chaquopy python 安卓
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 有没有帮写代码做实验仿真的
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥30 vmware exsi重置后登不上
  • ¥15 易盾点选的cb参数怎么解啊
  • ¥15 MATLAB运行显示错误,如何解决?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题