0

I'm developing a mobile application and am having trouble debugging my server-side code. I make cross-domain AJAX requests from the app. Normally, I would use var_dump() to display the contents of variables to the browser, but with these cross-domain requests, I can't figure out how to do something similar. What are some common methods that one might use to visualize what happens within the server-side script from a cross-domain perspective?

Here is the bulk of what my AJAX requests look like:

$.ajax({
        async: false,
        url: 'http://mysecretsite.com/page.php',
        data: mySecretData,
        dataType: 'jsonp',
        jsonp: 'callback',
        jsonpCallback: 'mySecretCallback',
        success: function(){
            alert("success");
        },
        error: function(xhr, status, errorThrown){
            alert("Oops: " + status);
        },
        complete: function(){
            alert("complete");
        }
});
Frumples
  • 425
  • 1
  • 4
  • 18
  • 1
    dump them into the json that you serve with jsonp? If they're not structured, just dump them into a json string – Bergi Sep 26 '14 at 16:19
  • possible duplicate -> http://stackoverflow.com/questions/323517/is-there-an-equivalent-for-var-dump-php-in-javascript – bhowden Sep 26 '14 at 16:19
  • 1
    You should not debug your server-side code in browser cross-domain requests at all. In debugging, you can use whatever client you want to call your serverside script, using the mobile app for that is not useful – Bergi Sep 26 '14 at 16:20
  • @bhowden: No, it's not. He is really trying to debug his PHP – Bergi Sep 26 '14 at 16:21
  • @Bergi So, maybe I should be trying to figure out how to pass JSON data using the browser? Such as www.site.com/page.php?data=JSON_DATA – Frumples Sep 26 '14 at 16:25
  • 1
    ^ that or just change the script to pull in the json file for testing purposes. – Bioto Sep 26 '14 at 16:34
  • The comments have answered my question. I will work with these new methods until I feel confident enough to post an answer; otherwise, putting your suggestions into a more full answer would be beneficial to myself and anyone else in a similar situation. Thanks! – Frumples Sep 26 '14 at 16:40

0 Answers0