In drupal.js 4.7 there is a HTTPGet, it's not existing in 5.0.

Or the function got by accident forgotten, or (more likely) there is a new 5.0 way to work with it. I'm using this function for Ajax stuff, so it seams important.

However I didn't find any info on the 4.7 => 5.0 page or any other page to explain me how to work with it now. It may be hidden in other information, maybe its just a problem of visibility?

Comments

cburschka’s picture

Title: HTTPGet where did it go? » drupal_http_request

That's the function you're looking for.

cburschka’s picture

Title: drupal_http_request » Whoops, sorry

I missed the Javascript bit and thought you were talking about the PHP API. Disregard the above.

cburschka’s picture

Title: Whoops, sorry » HTTPGet where did it go?

Erm. I'm new to the issues, I guess. Here's the original title restored.

Anonymous’s picture

hey mixel..

with having jQuery now in 5.. we don't need this method anymore.

jQuery has better ways of handling AJAX..

there is now $.ajax(); or $.get();

both will do what you want.

to find out jQuery methods, visit: http://jquery.com/api/

everything in it has examples so it's right easy to pick up. hope that helps.

profix898’s picture

Category: bug » support
mixel’s picture

well tried the $.get and $.ajax stuff. there are several examples, but a simple httpget ... didn't got it working got "undefined" all the time. I simply whant this:

thisid = jqselect_HTTPGet(url);

where the "url= http://www.knosos.be/update5/?q=ajax/check_user_name/mixel"
it should return an id or "false", but I'm not gething any thing.

What I did learn is that I could use more jquery functions to make my script look nicer. Don't think I'll have the time for it sadly

mixel’s picture

ow, copy past the HTTGET to a local function jqselect_HTTGET for the moment to make the script work

scroogie’s picture

Perhaps we can help you when you specify a bit more what you want to do. When it didnt work with get(), did you get errors in your javascript console?

Steven’s picture

mixel: I suggest you look at a usage of HTTPGet in Drupal 4.7 .js, and look at the equivalent code in Drupal 5.0. The jQuery API changes are too numerous to mention sadly... there is plenty of code which can be optimized with it.

But, feel free to update the module upgrading guide with a specific snippet for HTTPGet, if you think it would be useful.

mixel’s picture

That was a good idea Steven.
I found a example in autocomplete.js where the 'search' is using the ajax in 5.0 and the HTTPGET in 4.7.

My problem stays however, always got tot the 'error' part of the ajax never the 'success'. My problem I belief is with the url, some how I never get it there. The url is:

"http://www.knosos.be/update5/?q=ajax/check_user_name/mixel" (mixel is the input part)

The problem I think is that the ajax you don't need to specify the path (seen it in other examples) but I'm not sure what that means, displaying the "this.uri" gives undefined and I'm thinking it may be the current path of the module that may (.../update5/module/...). Giving the whole url doesn't work, only the query part doesn't work, testing the moduel dir didn't work ... I simply have no clue.

scroogie’s picture

Can you try the following just as a test?

 $.get("/update5/index.php",
   { q: "ajax/check_user_name/mixel"},
   function(data){
     alert("Data Loaded: " + data);
   }
 );
mixel’s picture

your sugestion did give me results, so tnx.
I couldn't really run the code, so can't give feedback on that, the next code worked:

$.ajax(
{
type: "GET",
url: "/update5/index.php/?q=ajax/check_user_name/mixel",
success: function (thisid)
{
alert('Data '+ thisid);
},
error: function (xmlhttp)
{
alert('An HTTP error '+ xmlhttp.status +' occured.\n'+ this.uri);
}

mixel’s picture

Status: Active » Fixed

forget to close the the ajax past so add:

});

Anonymous’s picture

Status: Fixed » Closed (fixed)