Easy A
Would you like to react to this message? Create an account in a few clicks or log in to continue.


 
HomeHome  Latest imagesLatest images  SearchSearch  RegisterRegister  Log inLog in  

Share
 

 Ajax problem

View previous topic View next topic Go down 
AuthorMessage
DeathMatch
Member
Member
avatar

Posts : 6
Join date : 2011-03-26

Ajax problem Empty
PostSubject: Ajax problem   Ajax problem EmptySat May 14, 2011 7:40 pm

Hello, first I have a code with ajax and cannot operate the onChange.ALso
it cannot see the picture.
Code:

<select name="cs"  onChange="ajaxRequest(this)">

<div id="result"> </div>

Code:

function ajaxRequest(){
  var activexmodes=["Msxml2.XMLHTTP", "Microsoft.XMLHTTP"] //activeX versions to check for in IE
  if (window.ActiveXObject){ //Test for support for ActiveXObject in IE first (as XMLHttpRequest in IE7 is broken)
  for (var i=0; i<activexmodes.length; i++){
    try{
    return new ActiveXObject(activexmodes[i])
    }
    catch(e){
    //suppress error
    }
  }
  }
  else if (window.XMLHttpRequest) // if Mozilla, Safari etc
  return new XMLHttpRequest()
  else
  return false
 }

 var mygetrequest=new ajaxRequest()
if (mygetrequest.overrideMimeType)
  mygetrequest.overrideMimeType('text/xml')
 mygetrequest.onreadystatechange=function(){
  if (mygetrequest.readyState==4){
  if (mygetrequest.status==200 || window.location.href.indexOf("http")==-1){
  var xmldata=mygetrequest.responseXML //retrieve result as an XML object
    var rssentries=xmldata.getElementsByTagName("pmdata")
    var output='<ul>'
    for (var i=0; i<rssentries.length; i++){
    output+='<li>'
    output+='<a href="'+rssentries[i].getElementsByTagName('picture')[0].firstChild.nodeValue+'">'
    output+=rssentries[i].getElementsByTagName('name')[0].firstChild.nodeValue+'</a>'
    output+='</li>'
    }
    output+='</ul>'
    document.getElementById("result").innerHTML=output
  }
  else{
    alert("An error has occured making the request")
  }
  }
 }

 mygetrequest.open("GET", "http://outranet.scm.tees.ac.uk/users/u0000700/wes_ica_09_10/ukpm.php", true)
 mygetrequest.send(null)

in php file

Code:

<prime_minister>
<pmdata>
<name>
Herbert Henry Asquith
</name>
</pmdata>
<pmdata>
<dates>
 1908-16
</dates>
</pmdata>
<pmdata>
<number>
35
</number>
</pmdata>
<pmdata>
<picture>
http://www.number-10.gov.uk/files/images/OLD%20PMs%20-%20H%20H%20Asquith.jpg
</picture>
</pmdata>
</prime_minister>
Back to top Go down
Momment
Member
Member
Momment

Posts : 19
Join date : 2011-03-09

Ajax problem Empty
PostSubject: Re: Ajax problem   Ajax problem EmptySat May 14, 2011 7:41 pm

I'll check it out.
Back to top Go down
 

Ajax problem

View previous topic View next topic Back to top 
Page 1 of 1

 Similar topics

-
» What happens when ajax call is invoked?
» (AJAX => Div) don't work javascript in the div
» Facebook Login with AJAX Calls
» Ajax/jQuery Form $_POST and use PHP?
» PC problem

Permissions in this forum:You cannot reply to topics in this forum
Easy A :: Ajax problem Edit-trash Useless :: Trash-