0

I declared a variable as global inside

var orid ;

then I used get function inside query from Parse.com ((Here "orid" doesn't save the info ))

    query.get("ZL8OcUjnJX", {
        success: function(object) {
    orid = object.get("OrderId");
        },

        error: function(object, error) {
        // error is an instance of Parse.Error.
        }
        });

Then I used This function in order to use it inside html tag (( it shows undefined doent show the data from previous function))

    function showinfo(){
        document.write(orid);}

and I called it inside the html tag to print it in the page

    <td id="intro"> 
   <script type="text/javascript"> 
          showinfo();
   </script> 
  </td>

The problem is when I wanna this information to appear in webpage it doesn't do. Also, when I tried

document.write(orid);

inside function "get" it overwrite the page at all

Noha
  • 15
  • 5
  • 4
    Welcome to the wonderful world of **async**! You can't do that. Instead, use the DOM APIs inside the callback. – SLaks Apr 28 '14 at 19:13
  • Have a look at [How to return the response from an AJAX call?](http://stackoverflow.com/questions/14220321/how-to-return-the-response-from-an-ajax-call) for an explanation of the problem and possible solutions. Moving the function call inside the `get` success callback is correct, just don't use `document.write`. – Felix Kling Apr 28 '14 at 19:15
  • Also, `document.write` is likely going to obliterate everything you have anyway... – Lee Taylor Apr 28 '14 at 19:16
  • I took a look at the link you for AJAX but i did not use before the AJAX so I will need a time to learn it ,, is there any simple way to print data instead of using "document.write" @FelixK – Noha Apr 28 '14 at 20:45
  • You can use `console.log`. [Learn how to debug JavaScript](http://www.creativebloq.com/javascript/javascript-debugging-beginners-3122820). – Felix Kling Apr 28 '14 at 20:49

0 Answers0