A community in which webmasters can ask for help with topics such as PHP coding , MySQL , IT jobs, web design, IT security.
Current location:homephp forumphp talk in 2008 yearJavaScript function not responsive - page 1
User InfoPosts
JavaScript function not responsive#1
I have the following code, which is the core part of my small AJAX application. I am not getting any errors, it is just that nothing happens. I am guessing there is a more efficient way to do what I am trying to do.

Here is the code:

var xmlHttp

var layername

function update(layer, part, pk, query)


if (part=="1")


$url "get_auction.php?cmd=GetAuctionData&pk="+pk+"&sid="+Math.random()


else if (part=="2")


var url "get_records.php?cmd=GetRecordSet&query="+query+"&sid="+Math.random()





alert("Your browser is not supported?")


xmlHttp.onreadystatechange = function() {

if(xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {


} else if (xmlHttp.readyState==1 || xmlHttp.readyState=="loading") {







function GetXmlHttpObject()


var xmlHttp=null;



xmlHttp=new XMLHttpRequest();

}catch (e)




xmlHttp =new ActiveXObject("Microsoft.XMLHTTP");


catch (e) {}


return xmlHttp;


function makewindows(){

child1 = window.open ("about:blank");

child1.document.write(json_encode(<?php echo $row2["ARTICLE_DESC"]; ?>));



and an example of how I am calling the function from php


pk or query will never be passed at the same time, only one of them will ever be passed.

edit: I am also wondering if it would make more sense for the makewindows function to take a parameter, or stay as it is. Are there advantages and disadvantages for each approach?

posted date: 2008-12-10 04:15:00

Re: JavaScript function not responsive#2
I had made out the solution of this problem. click to view my topic...

hope that hepls.

posted date: 2008-12-10 04:15:01

Re: JavaScript function not responsive#3
whats with all the "\" ? Those are escape chars in javascript.

posted date: 2008-12-10 04:47:00

Re: JavaScript function not responsive#4
I'd check the HTML the PHP is generating. Assuming $pk is a string it looks like you're missing an opening quote. Try this:onclick="update(\'Layer3\',\'2\',\''.$pk.'\',\'0\',)">

posted date: 2008-12-10 04:50:00

Re: JavaScript function not responsive#5
json_encode is a PHP function, and thus you need to modify that particular line like so:child1.document.write(<?php echo json_encode($row2["ARTICLE_DESC"]); ?>);

posted date: 2008-12-10 06:39:00

Re: JavaScript function not responsive#6
Looks like you may have some javascript errors:if (part=="1"){ $url "get_auction.php?cmd=GetAuctionData&pk="+pk+"&sid="+Math.random()}else if (part=="2"){ var url "get_records.php?cmd=GetRecordSet&query="+query+"&sid="+Math.random()}Use Firefox and Open the javascript console to get the javascript errors, then try to fix the lines it complains about.Javascript will stop running as soon as it encounters an error.Also, checkout firebug if you haven't already. Great tool!

posted date: 2008-12-10 06:57:00

Re: JavaScript function not responsive#7
I'm not understanding your question. Do you want us to check your logic or your code?

posted date: 2008-12-10 10:06:00

Re: JavaScript function not responsive#8
The code first, as it does not seem to be wondering, and I am not sure if it is ok to have two parameters if only one is used..., even if my code works i would like to know if it is the best way to do what i want to do.

posted date: 2008-12-10 12:14:00

select page: « 1 »
Copyright ©2008-2017 www.momige.com, all rights reserved.