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 3 of 3
  1. #1
    Regular Coder
    Join Date
    Mar 2005
    Location
    Pakistan
    Posts
    207
    Thanks
    0
    Thanked 0 Times in 0 Posts

    function importXML('test.xml'); this works but...

    hi sir h r u?
    sir i am facing very seriouse prg plz help me i have function i.e
    -----------
    var test_array = new Array();
    function importXML(file_name)
    {
    var temp_var = new Array();

    if (document.implementation && document.implementation.createDocument)
    {
    xmlDoc = document.implementation.createDocument("", "", null);
    xmlDoc.onload = createTable;
    }
    else if (window.ActiveXObject)
    {
    xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
    xmlDoc.onreadystatechange = function () {
    if (xmlDoc.readyState == 4)
    temp_var = createTable()
    for(i = 0; i < temp_var.length; i++) {
    if(temp_var[i] != ''){
    test_array.push(temp_var[i]);
    }
    }

    }

    }
    else
    {
    alert('Your browser can\'t handle this script');
    return;
    }
    xmlDoc.load(file_name);

    return test_array;
    }

    -----------
    i call this function like this

    function importXML('test.xml');

    "this function works very fine but the requirement is this i have to give this code to my client and he can run this but he have to get xml file from my server like this"

    function importXML('http://www.naeembhatti.com/test.xml');
    it does not work for him and display the error in javascript "access denied", i think when he can't access the file then he display this error but when i use this code in my domain(www.naeembhatti.com) it works fine.

    my question is give me a solution to XmlLoad('www.naeembhatti.com/test.xml'); and it will work how?
    plz plz help me i have deadline tom.
    God helps those who help others.

  • #2
    Master Coder
    Join Date
    Feb 2003
    Location
    Umeå, Sweden
    Posts
    5,575
    Thanks
    0
    Thanked 83 Times in 74 Posts
    JavaScript has a security policy based on only allowing scripts access to resources from the same domain (The Same Origin Policy). So there is no solution to this other than putting the resources you want to access and the page you want to access them on the same domain.
    liorean <[lio@wg]>
    Articles: RegEx evolt wsabstract , Named Arguments
    Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
    Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards

  • #3
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    Look into this: http://ajaxextended.com/

    Eric
    Tech Author [Ajax In Action, JavaScript: Visual Blueprint]


  •  

    Posting Permissions

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