/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] ajax troubles

Hi!

I have a problem with my ajax function.

The functions makes text within <p>text</p> reappear as an editable textarea if you press it.

And when you change it and press ok, it goes back, while sending information to another php site, which makes changes in a database (according to the <p [B]id=”what_to_change”[/B]>text</p>

The problem is that somehow, I cant make it work with changing the text to more than 20 letters…

[CODE]var xmlHttp

// bör man lägga till document.getElementById(txt1) innan det andra??
window.onload=function() {

var qa = document.getElementById(‘txt1’).value;
var wa = document.getElementById(‘txt2’).value;
var ca = document.getElementById(‘txt3’).value;
var da = document.getElementById(‘txt4’).value;
}
// bör man lägga till txt1.qa?
function showUsera(qa, wa, ca, da)
{
//if (qa.length < 2)
//{
//document.getElementById(“txtHint”).innerHTML=”Skriv in minst 3 siffror/bokstäver”
//return
//}

xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
{
alert (“Browser does not support HTTP Request”)
return
}

var url=”geten.php”
url=url+”?q=”+qa+”&w=”+wa+”&c=”+ca+”&d=”+da
url=url+”&sid=”+Math.random()
xmlHttp.onreadystatechange=stateChanged
xmlHttp.open(“GET”,url,true)
xmlHttp.send(null)
}

function stateChanged()
{
if (xmlHttp.readyState==4 || xmlHttp.readyState==”complete”)
{
document.getElementById(“txtHint”).innerHTML=xmlHttp.responseText
}
}
function GetXmlHttpObject()
{
var xmlHttp=null;
try
{
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
}
catch (e)
{
// Internet Explorer
try
{
xmlHttp=new ActiveXObject(“Msxml2.XMLHTTP”);
}
catch (e)
{
xmlHttp=new ActiveXObject(“Microsoft.XMLHTTP”);
}
}
return xmlHttp;
}[/CODE]

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@lorkanauthorMay 18.2008 — hi!

I justed wanted to tell that the problem was solved with some help... and that the problem was not in the ajax or java. The problem was in the sql query and the db.

A tip to you all in the future:

make sure you give a lot of extra space in the db. never give a varchar less than 128!
×

Success!

Help @lorkan spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.1,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...