0

I have some little problem with understanding mockjax. I have this mockjax code:

$.mockjax({
  url: "get_image.php",
  responseText:{
    hello: 'world'
  }  
});

What should be js code to alert 'world'? Maybe this?

$.getJson("url" , function(){
  alert(response.hello)
});

But this is not working, please help me!

Jordan Kasper
  • 13,153
  • 3
  • 36
  • 55

1 Answers1

0

You forgot to add argument response in function.

$.getJson("url" , function(response){
  alert(response.hello);
});

Read more about getJson()

Gopal Joshi
  • 2,350
  • 22
  • 49
  • this is steal not working, response.hello os undefinded , maybe the error in mockjax code, can u check it? But i think this is correctly – Vlad Drakula Nov 14 '16 at 10:25
  • Can you please update question with value of `response` ? It says it element `hello` not found in `response`. – Gopal Joshi Nov 14 '16 at 10:42