It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming JavaScript Forum

little problem with one java script

little problem with one java script

Postby siggeba on Thu Mar 05, 2009 9:07 pm

Code: Select all
function ajaxform(){
   var ajaxRequest;  // ajax
   
   try{
      // Opera 8.0+, Firefox, Safari
      ajaxRequest = new XMLHttpRequest();
   } catch (e){
      // Internet Explorer Browsers
      try{
         ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
      } catch (e) {
         try{
            ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
         } catch (e){
            // Something went wrong
            alert("Your browser broke!");
            return false;
         }
      }
   }
   // Detta er sent til serverinn
   ajaxRequest.onreadystatechange = function(){
      if(ajaxRequest.readyState == 4){
         var ajaxDisplay = document.getElementById('ajaxDiv');
         ajaxDisplay.innerHTML = ajaxRequest.responseText;
      }
   }

   var fran = document.getElementById('franvaluta').value;
var till = document.getElementById('tilvaluata').value;
   var summa = document.getElementById('summa').value;
   var queryString = "?fran=" + fran + "&till=" + till + "&summa=" + summa;
   ajaxRequest.open("GET","includes/valuta.php" + queryString, true);
   ajaxRequest.send(null);
   


last line in form is like
<input class="valutabuttom" type='button' onclick='ajaxform()' value='Valitera' />
</form>



Okei my problem is that when i get on homepage like index.php , this code works fine but when i get on page like
http://www.site.com/katagories/something/something.htm this script dont work , ive tried to change like
Code: Select all
   ajaxRequest.open("GET","[b]/[/b]includes/valuta.php" +

but without anyluck. Maybe someone here can help me with soulution.
siggeba
 
Posts: 1
Joined: Thu Mar 05, 2009 9:00 pm

Re: little problem with one java script

Postby rangana on Fri Mar 06, 2009 2:23 am

Ensure that the URL is correct:
Code: Select all
includes/valuta.php


If this works on "index.php", I"m assuming that index.php has a folder named "includes" in the same directory of its location and a file named "valuta.php" is existing there.

If you're referring to your page as something like:
http://www.site.com/katagories/something/something.htm

...then you have been into two subfolders (just after the root), so you need to change the URL path.

I'm uncertain, but changing this:
Code: Select all
ajaxRequest.open("GET","includes/valuta.php" + queryString, true);


to this:
Code: Select all
ajaxRequest.open("GET","../../includes/valuta.php" + queryString, true);


or:
Code: Select all
ajaxRequest.open("GET","/includes/valuta.php" + queryString, true);


...might help
User avatar
rangana
500+ Club
 
Posts: 935
Joined: Wed Feb 27, 2008 5:14 am
Location: Cebu City Philippines


Who is online

Users browsing this forum: No registered users and 8 guests