0

I have a script that extracts the p elements in a document using jQuery. With jQuery I map these to a normal array. I was just looking for some insight on how to store this in a database through jQuery.

EDIT: I use jQuery to scrape the p elements on a set of pages

var textnode = $(source).children("p:not(:has(img))").map(function() {
    return $(this).outerHTML();
    }).get();

I was wondering how I would get started on storing this array into a database

3
  • Serverside? Clientside? What are you trying to do? Code? Commented Jun 26, 2011 at 23:58
  • it really depends on how you're modelling your data - are you trying to store each element from the array in its own record? Commented Jun 27, 2011 at 0:02
  • yes im trying to assign each <p> with its own id. Commented Jun 27, 2011 at 0:04

1 Answer 1

1

Typically, jQuery does not talk directly to a database. The main issue is that jQuery usually runs on the client side and databases for web applications are typically (although, of course, not always) on the server side.

In a few cases, storing the information client-side via HTML5 or something else might be an option. In most cases, that will result in problems around varying levels of HTML5 support in different versions of different browser and/or might be inappropriate for other reasons (such as perhaps multiple clients need to be able to read the same data back).

In some cases, it may be OK to send the data to a server (via any number of ways: .ajax() is one) that can store it in a database. In many cases, there will be issues around security/encryption/privacy with this approach.

Sign up to request clarification or add additional context in comments.

2 Comments

can the values in a normal array generated by jquery be accessed by a php script?
Typically, jQuery runs on the client side and PHP runs on the server side. So, in the typical set up, the answer is no.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.