Jump to content

Just A Little Confirmation On Ajax :)


Kingy

Recommended Posts

Hey guys, I know I got another topic open but whilst that's lying unresolved for the time being, I just wanted to see if something else I want to do is possible.I have this form as the first part of an upload form, so after filling in details you go to the next page to upload stuff.But naturally I don't want people to type the same things again and again on repeat visits, so I'd like to make an autofill function in Ajax.I've only dabbled with Ajax and only just starting to grasp the basics of PHP so I'm not vastly knowledged in it.So what I'd like to know is if a form like this with multiple fields can be filled by typing in a key field (like in my case name of artist/group)http://empulse.dmu.ac.uk/upload/Submission%20Upload.htmAt the moment I'm thinking about Ajaxs ResponseXML property, and getting the data from an XML file.Does this sound like something that can easily be done? Sorry for being such an Ajax noob. :)I just don't want to go through a huge learning + setup process, only to find out it can't be done.

Link to comment
Share on other sites

I'm not entirely sure of the question. Lots of documents come prefilled because PHP has stored the data somewhere and then fills the form when the document is being processed, at download time.You could certainly request an XML file through AJAX and use its data to fill all kinds of things. My current project does exactly that. XML DOM methods built into your browser simplify the process of extracting data from the XML Object.So if the plan is to use AJAX to fetch an XML file and fill in form fields with data in the XML file, yes, it's a pretty simple task.On the other hand, getting a reference to an XML DOM node (and the text data inside it) requires a kind of convoluted syntax that you need to get used to. Nothing that'll break your head open, though. :)

Link to comment
Share on other sites

Right well what I ideally want is if I type in something in the keyfield (artists name), it brings up suggestions of saved people in the past and then when I click on one it fills in all the other parts of the form. Of course I'd like it to fill multiple fields in one go, so the user doesn't have to fill in each individual detail.Yes I've had a look into the XML DOM nodes, looks somewhat fiddly but if that is the kind of thing I need to do it shouldn't be a huge deal, just a bit of a time muncher I think? :)

Link to comment
Share on other sites

So the XML doc resides on the server. The user types in characters and names like that start getting downloaded. When the user chooses one, the correct XML doc is downloaded.Is that it?Fetching names based on entered characters will probably go faster if (1) you're searching a database rather than XML, and (2) you send the information back in JSON format. One of the nicest things about XML is it can easily be parsed by human readers. But tag names and closing tags take up SPACE, and SPACE increases transmission time. Transmitting a small array literal (JSON) is wicked fast, even to a user with 128K bandwidth.But when you have identified the correct name, sending an XML file should not be a big deal, and the JavaScript API for searching an XML DOM is pretty straightforward. I prefer XML when the data would otherwise require several large multidimensional arrays. Like if I had 30 customers and they required 5 data fields each, and I also had 20 types of insurance policies that they could choose from, and each one of those had 5 fields, and I also had a tree of zipcodes for my sales territory, and some of the fields in each of those three main branches match so I can do a relational thing, AND I want the info to be dynamic so I could send an updated XML doc back to my server -- in such a case, I find the overall process easier and less server intensive with XML. (A server script that accepts a serialized XML doc, quickly validates it, writes it to disk, and checks for read/write errors can come in at 500 bytes.)If the data is pretty simple (a 1 dimensional array with around 10 fields in all) then sending it one way (or even 2) in JSON format might be easier and save a little transmission time.Simply parsing a short (less than 50K) XML document in your browser's RAM is not noticeably slower than parsing strings and arrays. The amount of time involved will be less than a millisecond (seemingly instantaneous). The slowest part of filling a form is actually writing the data to the screen. But if you have less than 20 fields, that will also feel instantaneous. So browser parsing time should not really be a consideration.

Link to comment
Share on other sites

Yeah that sounds right.I see, that makes sense, I think the reason they wanted XML is because later when audio files are added the details would be saved into XML or something so they can search using meta tags later. Well the guy who is supposed to be working on the database has recently told me he won't be doing so for like another month and a half at least so that's very useful!So evidently there are pros and cons in each, but at this moment in time I can't make a full on decision yet as the others kinda need to help me in order to help them. :)But in terms of a more efficient way of dealing with this would be to assess file size and if we used JSON format to speed things up then.I haven't really touched on JSON before but definately worth considering when the time comes.There definately won't be more than 10 fields even to fill in so I don't think it would be a huge issue.I'll bring this up next time we speak collectively, thanks a lot that was very useful info. :)

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...