views:

72

answers:

1

Hi,

I've coded a bookmarklet that opens a new window at a certain URL and sends some variables to a PHP using GET. The problem is I need to have it load the same php and send the same variables but inside a div this time.

Could anyone point me in the right direction please?

A: 

Client Side - JavaScript & jQuery

jQuery provides a GET operation using AJAX, for example $.get("test.php"); See Ajax/Query.get docs for more info: arguments, examples, etc.

The version to send GET variables is $.get("test.php", { name: "John", time: "2pm" } ); jQuery is an API layer on top of regular JavaScript that simply wraps the lower-level features and expresses them in a somewhat cross-browser compatible way.

Server Side - PHP

This w3schools page shows a sample of a PHP page picking up GET data from an AJAX call:

<?php
$name=$_GET["name"]; // John
$time=$_GET["time"]; // 2pm
John K
Well the thing is I need this working inside of a bookmarklet. I can't include jquery on all pages i need to run this bookmarklet on. Any ideeas on this?
Carvefx
You can include jQuery script on all pages that have the bookmarklet if you use `<script type="text/javascript" src="jquery132.js"></script>` or put this in the bookmarklet. Additionally you can inject JavaScript wherever a link would be used, for example `<A HREF="javascript:YourStuff();window.location=xyz">` for inside the bookmarklet.
John K