Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    Regular Coder Kevin_M_Schafer's Avatar
    Join Date
    Apr 2011
    Location
    Fairfax, Minnesota, U.S.A.
    Posts
    482
    Thanks
    97
    Thanked 17 Times in 17 Posts

    java script only runs with ip address and not domain name

    I have an unusual problem that just started yesterday.

    When visitors to my site go to the login page, to some the login boxes (e-mail address and password) don't show.

    http://www.theeagleextra.com/lp.html

    One of my computers in my office shows the script and some don't. So I know what my visitors mean when they say nothing shows up.

    If we use the ip address, then the script runs all the time.

    http://96.9.48.31/lp.html

    Any help would be greatly appreciated. Thanks.
    My keyboard is an IBM from 1993 and I like it that way. | Who is Dan Well? Everyone always says I know Dan Well.Building a web page is like building a birdhouse. Put it up there and watch 'em come. | Maintaining the aspect ratio of an image is more important than having a cold orange pop.

  • #2
    Regular Coder
    Join Date
    Jul 2002
    Location
    Kansas, USA
    Posts
    487
    Thanks
    0
    Thanked 54 Times in 53 Posts
    If you are using Ajax (as it looks like you are) then the Javascript same-domain* security policy applies. It appears you've hard-coded the ajax request using the IP, meaning accessing the page with the IP will work, any other access will not. Since the ajax routine is built in PHP you should probably make the ajax request dynamically use the host that was used to request the page. If the visitor is coming from the domain, use the domain to call the ajax, if the visitor is coming from the IP address, use the IP address to call the ajax.

    *In Javascript you are not allowed to access resources via XHR (Ajax, etc.) from a domain/IP different than the one the page is called from. That is, www.theeagleextra.com != theeagleextra.com (without www) and != 96.9.48.31 (or any subdomains or completely different domains or IPs).
    Last edited by kansel; 05-13-2011 at 09:25 PM. Reason: clarity

  • Users who have thanked kansel for this post:

    Kevin_M_Schafer (05-13-2011)

  • #3
    Regular Coder Kevin_M_Schafer's Avatar
    Join Date
    Apr 2011
    Location
    Fairfax, Minnesota, U.S.A.
    Posts
    482
    Thanks
    97
    Thanked 17 Times in 17 Posts
    kansel,

    I purchased the member login software from a company that installed it on my ftp site for me.

    It all worked up until just a couple of days ago. Why would it work for a few weeks and then not work? All the PHP files are still dated 3-20-11 -- the date they were uploaded.

    After I read your post, I changed the hyper links to using the ip address. Is this what you meant?
    My keyboard is an IBM from 1993 and I like it that way. | Who is Dan Well? Everyone always says I know Dan Well.Building a web page is like building a birdhouse. Put it up there and watch 'em come. | Maintaining the aspect ratio of an image is more important than having a cold orange pop.

  • #4
    Regular Coder
    Join Date
    Jul 2002
    Location
    Kansas, USA
    Posts
    487
    Thanks
    0
    Thanked 54 Times in 53 Posts
    I don't know why it would work and then not work.

    The code I am talking about is in http://www.theeagleextra.com/member/...oad_login.php:

    Code:
    MemberLogin.LoginSettings = {
    	URL: "http://96.9.48.31/member/",
    	uploadUrl: "http://96.9.48.31/member/uploads/",
    	installFolder: "/member/",
    	
    	messagesWrapper: document.getElementById("ml_login_messages"),
    	contentWrapper: document.getElementById("ml_login_content"),
    	
    	validationName: "Name",
    	validationEmail: "Email",
    	validationInvalidEmail: "Invalid email address",
    	validationPassword: "Password",
    	validationPhone: "Phone",
    	validationWeb: "Web",
    	validationLoginDataRequired: "Email and password are required."
    }
    
    MemberLogin.Ajax.get("http://96.9.48.31/member/frontend/include/login.php?1=1&ac=0", "ml_login_content");
    That's coded in Javascript but the src to that script is a php file so it should be possible to modify the PHP file to call the current host and not the hardcoded IP address.

    If you purchased this software you should probably contact the company for support.

  • Users who have thanked kansel for this post:

    Kevin_M_Schafer (05-13-2011)

  • #5
    Regular Coder Kevin_M_Schafer's Avatar
    Join Date
    Apr 2011
    Location
    Fairfax, Minnesota, U.S.A.
    Posts
    482
    Thanks
    97
    Thanked 17 Times in 17 Posts
    kansel,

    where did you get that fragment of code you posted? Is it something you and I can hack and make the changes ourselves?

    The company I bought the software from offers only 12 hours of customer service every day. I think they're on their off hours, because I'm not hearing from them.
    My keyboard is an IBM from 1993 and I like it that way. | Who is Dan Well? Everyone always says I know Dan Well.Building a web page is like building a birdhouse. Put it up there and watch 'em come. | Maintaining the aspect ratio of an image is more important than having a cold orange pop.

  • #6
    Regular Coder Kevin_M_Schafer's Avatar
    Join Date
    Apr 2011
    Location
    Fairfax, Minnesota, U.S.A.
    Posts
    482
    Thanks
    97
    Thanked 17 Times in 17 Posts
    kansel,

    I just thought of something, when I was building my site, I was using only my ip address. When I was finished, my hosting company that has my ftp transferred my domain name onto it. That's probably why it's configured for my ip address.

    The computer I'm using right now shows the script perfectly, but other computers don't.
    My keyboard is an IBM from 1993 and I like it that way. | Who is Dan Well? Everyone always says I know Dan Well.Building a web page is like building a birdhouse. Put it up there and watch 'em come. | Maintaining the aspect ratio of an image is more important than having a cold orange pop.

  • #7
    Regular Coder
    Join Date
    Jul 2002
    Location
    Kansas, USA
    Posts
    487
    Thanks
    0
    Thanked 54 Times in 53 Posts
    That code fragment came from http://www.theeagleextra.com/member/...load_login.php. You are calling that script (it is a javascript even though it's delivered via php) from within your page.

    I don't know enough PHP to help with modifying that to dynamically use the same hostname as the calling page, though it should be simple/trivial to do if you want to ask in the PHP forum.

    If you intend to only use the site via domain name now that it is set up, you could just modify the script to use the domain instead of the IP address and that should work.

    I don't know how/why it is working for you on one computer - it seems like you might have custom browser settings that are bypassing javascript's same-domain policy.

    Your best bet is still the company you purchased the script from, especially since they installed it. Ask them if they can re-configure it to work with your domain now that that is set up.

    You should make an offline backup of all files on your site (download everything via FTP) before you/they make any modifications.

  • Users who have thanked kansel for this post:

    Kevin_M_Schafer (05-14-2011)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •