Jquery URL

ITsolutionWizard
ITsolutionWizard used Ask the Experts™
on
I have URL with jquery and I don't want anyone to xml on the web. What is my option?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Distinguished Expert 2017

Commented:
What do you mean?Could you post an example?

Author

Commented:
function fnGetBondNameList(bondState) {
        $.ajax({
            url: "http://localhost:5489/BondList.xml",
            success: function (xml) {
                parseSelectXML(xml,"bondName","Bond",bondState)
            },
            error: function (xhr, ajaxOptions, thrownError) {
                alert("Status: " + xhr.status);
                alert("Error: " + thrownError);
            }
        });
    }
Most Valuable Expert 2018
Distinguished Expert 2018
Commented:
You could potentially mask the URL by creating a middle-ware script, but the nature of your script means that any user would be able to see the URL that you're posting your AJAX request to. To do this, you could create a file, such as getScript.php and point your AJAX to that. Code the php script to then pull in the XML from a URL and then deliver that content. While this would mask the URL of your actual XML file, it won't mask the URL of the getScript.php file, so it may not make sense to do that.

The fact that your script needs to get it's info from somewhere means that somewhere must be publicly accessible, and therefore viewable by the end user.

Maybe you could explain the thinking behind your requirements and we might be able to offer other suggestions. As it stands at the moment, your script needs to load in the data, so anyone can view that data (even if they just use the webdev tools available in all modern browsers)

Author

Commented:
Just show me in codes and maybe i can understand more what you mean. Thanks
Most Valuable Expert 2018
Distinguished Expert 2018

Commented:
//getScript.php
<?php
include('path/to/your/file.xml')

Open in new window

And then in your Ajax call:

url: 'getScript.php',

As I said, this won't stop people from being to load your XML file - that's not going to be possible because your page needs to be able to read it, so any user can also read it - that's just the way it works!!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial