Jump to content

duncanhall

Members
  • Posts

    11
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

duncanhall's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. At the moment I'm calling all my javascript from links and buttons with [i]onclick="sendRequest('$variable')"[/i]. Is there a way to call [i]sendRequest()[/i] from straight within the php code? i.e: [code]If ($x == $y) {     // call sendRequest() }[/code]
  2. Again, thanks for the repsonse. I have narrowed this down to a Firefox problem as I can see everything working in IE from my home PC but not Firefox. Interestingly, i've recently noticed a problem in hotmail when using firefox from my home PC. When viewing the main inbox, the set of js buttons running along the top (new, delete, junk etc.) dont seem to produce any results. The cursor changes to the pointer as expected, but nothing happens. Im thinking these two things are related, but don't know what the problem is. Any ideas?
  3. Haha, give me some credit!  :) Yes, I checked everything, could not see anything that gave any inclination as to what was wrong. I took everything back to absolute basics so I had 1 html file, 1 js file and 1 php file. The html file simply called the sendRequest function, the js file instantiated the XMLHttp Object, opened the php file and handled the repsonse. The php file simply echoed a string. I tested it with the firebug plugin, and the html link successfully called sendRequest. Firebug showed me that the php string was returned to the javascript, but it simply wouldnt appear on the page.  I spent hours pouring over the js, in particular the handleResponse function as it seemed to me that this is where the problem was, but still nothing. And the example I have on my live server works fine from here, and another PC ive tested it on, but not on my home PC. Is there anything, [b]anything[/b] you can think of that might be preventing it from working?
  4. I have a php/mysql photo gallery system that returns all images in the db. Presently, it outputs in the form of: [code] <a href="#"><img src="1.png"></a><a href="#"><img src="2.png"></a><a href="#"><img src="3.png"></a><a href="#"><img src="4.png"></a> .......... [/code] For the sake of cleaner html, I add a \n newline after each image, giving me: [code] <a href="#"><img src="1.png"></a> <a href="#"><img src="2.png"></a> <a href="#"><img src="3.png"></a> <a href="#"><img src="4.png"></a> .......... [/code] which is what I want, but then the images cease to display properly? Any ideas ?
  5. After toying with my first bit of AJAX yesterday, I managed to accomplish what I intended and was pleased with my results. I uploaded everything to my testing server and everything was working fine. I then got home and tried to view the live example on my home PC, and all AJAX functionality had disappeared. I downloaded all neccessary files and scripts and battled for hours trying to get it to to work locally, but to no avail. I tried taking everything back to absolute basics and I still could not produce any results. I then come back to work this morning, and lo and behold, the live example is working fine, exactly as I left it. Does anyone know of any reasons why my home PC would fail to respond to all AJAX scripts, local or on the net? This is really puzzling me.
  6. Sorry, poor explanations on my part. I have trouble understanding exactly what's going on myself at times. Right, assuming I'm happy with my current methodology (at least for now), I have a slightly different question: After reading several other threads, it appears there's a discrepancy over using session variables. Will this be a problem for me if I just use the php script I already have to create a session variable. i.e. [list] [*]User clicks link. [*]JavaScript is processed. [*]PHP script is run, which returns the strings as before but now also sets a session variable. [*]JavaScript Response handler is processed. [/list] Will this session variable remain set regardless of refreshes or site navigation?
  7. There's no formatting issues, the string is presented in the PHP and returned just as I want it. There's no real 'work' being done to the data once it's returned. It's simply fed into a page element as below: [code]      var response = http.responseText;       if(response) {         document.getElementById("small").innerHTML = response.slice(0, 54);         document.getElementById("large").innerHTML = response.slice(55, 109);       } [/code] whereas what I wanted to do was something like: [code]      var response = http.responseText;       if(response) {         document.getElementById("small").innerHTML = response[0];         document.getElementById("large").innerHTML = response[1];       } [/code] Looking at it, I guess it doesn't really make a lot of difference, and as I said, it's doing everything I need it to. It's just I only started 'learning AJAX' about 5 hours ago, and I haven't been going at PHP for all that  long either, so I don't want to get into bad habits early on.
  8. Thanks for the responses, I have found a temporary solution that works satisfactorily, but for future purposes, perhaps I should ellaborate on the problem. I have two text links. When each one is clicked, I want the PHP/JavaScript combination to return two distinct values. i.e: click link 1: return stringA and stringB click link 2: return stringX and stringY Using my current method, the value returned by the PHP script is fed back to the javaScript as [i]XMLHttpRequest.responseText[/i]. This means I can only access the returned value as a whole, not as two seperate strings. Currently, I have solved the problem by concatenating the two strings in PHP and returning them as one long string. I then used the javaScript [i]slice[/i] method to split them into two seperate strings. Alhough this works, I thought It might be possible to pass an array from the PHP to the javaScript so that I could have two wholly seperate variables. Any comments?
  9. I'm trying to experiment a little with AJAX, but don't have a lot javaScript experience, so any help on this would be very much appreciated. I have my javaScript, which instantiates the [i]XMLHttpRequestObject[/i], and I then use the [i]open[/i] method of this object to open a PHP script to do some processes. At the moment, the PHP simply returns a string and this is then handled by the javascript to update a string on the page. Pretty simple, and working fine. But does anyone have any help as to how I can return an array from the PHP, rather than just a string, and then traverse this array accordingly in the javaScript?
  10. Cheers Liam, that worked! businessman, would you mind elaborating on "It's ALWAYS safer to run your query's through a variable"? Would you suggest using phpMyAdmin to configure my tables?
  11. So today I decided to make "the switch" from .NET to PHP and, being very new, need a little help. I have been following a simple tutorial to create a login/out page with a MySQL database. I have a "create_table.php" page which returns the following error: [b]Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING  on line 6[/b] the code is: [code] <?php require_once('connect.php'); mysql_query('CREATE TABLE `users` ( `id` int(11) NOT NULL auto_increment, `username` varchar(20) NOT NULL default '', `password` varchar(32) NOT NULL default '', `date_registered` int(10) NOT NULL default '0', `last_seen` int(10) NOT NULL default '0', PRIMARY KEY (`id`) )'); echo 'Table created'; ?> [/code] Any help on this would be most appreciated.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.