Custom http POST for search
Posted: 04 July 2008 08:23 AM   [ Ignore ]  
Grad Student
Avatar
Rank
Total Posts:  51
Joined  03-27-2007

Hi all,

I’m working on a Ajax-ified version of a searchfield. Now in my case this means that i must do a POST to the site root with the proper attributes and values to get a searchquery to EE.

In javascript i create an XMLHttpRequest and tried to send the following POST command.

http://myeeinstallation.com/?ACT=19&XID=fac52bed0908110e475d3b519997142edbe739a9&RP=search/results&NRP;=&RES;=&status;=&search;_in=&site_id=1&keywords=tryout&search_in=titles&where=exact&weblog;_id[]=null&cat;_id[]=all&member;_name=&date=0&date_order=newer&orderby=date&sort_order=desc'

I specified to the XMLHttpRequest object that i’m using the POST method. Unfortunately i get the following response back from the XMLHttpRequest object;

Invalid GET Data

Is there anyone that might have some pointers to help me out?

Thanks in advanced for your effort.

Rutger

 Signature 

Greate | Zwolle, The Netherlands | Photography · Design · Complete

Profile
 
 
Posted: 04 July 2008 10:08 AM   [ Ignore ]   [ # 1 ]  
Administrator
Avatar
RankRankRankRankRankRankRank
Total Posts:  15831
Joined  06-03-2002

If you’re sending POST data, then you don’t need the GET variables you are putting in your URL, Rutger.  Some of the characters you have in there (specifically the brackets), ExpressionEngine views as potentially malicious in the URL and will block the request.  But again, if you are POSTing data, you only need to hit http://example.com/index.php?ACT=19 (or whatever your action ID is).

 Signature 
Profile
MSG
 
 
Posted: 04 July 2008 12:20 PM   [ Ignore ]   [ # 2 ]  
Grad Student
Avatar
Rank
Total Posts:  51
Joined  03-27-2007

Derek,

Thank you for your reply. I guess i am a bit further since i now have the

The search path contains an error. Please contact the system administrator.

error message.

There isn’t a solution in doing a GET request to search my EE site is there?

 Signature 

Greate | Zwolle, The Netherlands | Photography · Design · Complete

Profile
 
 
Posted: 04 July 2008 12:57 PM   [ Ignore ]   [ # 3 ]  
Administrator
Avatar
RankRankRankRankRankRankRank
Total Posts:  15831
Joined  06-03-2002

I don’t follow, Rutger, you now want to use a GET request for the search?  The error you are receiving is due to there not being an ‘RP’ field in the submitted POST data, the results page path.

 Signature 
Profile
MSG
 
 
Posted: 04 July 2008 01:13 PM   [ Ignore ]   [ # 4 ]  
Grad Student
Avatar
Rank
Total Posts:  51
Joined  03-27-2007

Derek,

When i started developing this search feature i was under the assumption that a GET request wasn’t possible to use for EE searches. It would make things easier for me if there is. If there is, i’m not aware of it and someone might enlighten me. That’s why i mentioned it.

Now when i do use the RP field in my POST http request i get another error message;

Invalid GET Data

So i’ll keep trying to see what i’m doing wrong. I am spending hours on this one, i might as well keep going smile

 Signature 

Greate | Zwolle, The Netherlands | Photography · Design · Complete

Profile
 
 
Posted: 04 July 2008 01:43 PM   [ Ignore ]   [ # 5 ]  
Administrator
Avatar
RankRankRankRankRankRankRank
Total Posts:  15831
Joined  06-03-2002

If you’re getting an invalid GET data error, then the problem is with the URL your Ajax method is accessing.  Are you rolling your own request or using a library like JQuery?  The latter would certainly be easier.

And no, there’s not a direct way to use GET with the Search Module.  It could be done, but you’d have to have an intermediary page request that took the GET and sent its own POST request, so you might as well skip the middle man.

 Signature 
Profile
MSG
 
 
Posted: 04 July 2008 01:50 PM   [ Ignore ]   [ # 6 ]  
Grad Student
Avatar
Rank
Total Posts:  51
Joined  03-27-2007

You’re right, JQuery would probably be a better choice. But i like to do it ‘head first’. Stupid me smile
I’m trying this using the method described here http://www.captain.at/howto-ajax-form-post-request.php

I don’t get the invalid data error anymore, so i’m getting closer i guess. If i manage to pull this off i think i’ll be writing a guide to do this.

 Signature 

Greate | Zwolle, The Netherlands | Photography · Design · Complete

Profile
 
 
Posted: 04 July 2008 02:01 PM   [ Ignore ]   [ # 7 ]  
Administrator
Avatar
RankRankRankRankRankRankRank
Total Posts:  15831
Joined  06-03-2002

I’m sure other users would agree; it would make a great Wiki article, Rutger!

 Signature 
Profile
MSG
 
 
Posted: 04 July 2008 02:13 PM   [ Ignore ]   [ # 8 ]  
Grad Student
Avatar
Rank
Total Posts:  51
Joined  03-27-2007

Ok, i will write one when i finish this successfully!

Good news, i’ve managed to complete the issue described above, but now it comes down to browser compatiblity.

The only issue i’ve got now, that with every character i type, a searchquery is executed resulting in the message;

You are only allowed to search every 15 seconds.

Any idea on how to be able to prevent this?

 Signature 

Greate | Zwolle, The Netherlands | Photography · Design · Complete

Profile
 
 
Posted: 04 July 2008 02:19 PM   [ Ignore ]   [ # 9 ]  
Administrator
Avatar
RankRankRankRankRankRankRank
Total Posts:  15831
Joined  06-03-2002

Ah, if you’re having it send the query live for each keypress, you’ll need to do one of two things (or both):

1) put a delay in the js so it only triggers after you’ve stopped entering new keypresses for a few moments
2) adjust or remove the search throttling in the Membership Preferences

 Signature 
Profile
MSG
 
 
Posted: 04 July 2008 03:02 PM   [ Ignore ]   [ # 10 ]  
Grad Student
Avatar
Rank
Total Posts:  51
Joined  03-27-2007

Great, thanks for the feedback!

 Signature 

Greate | Zwolle, The Netherlands | Photography · Design · Complete

Profile
 
 
Posted: 06 July 2008 10:15 AM   [ Ignore ]   [ # 11 ]  
Moderator
Avatar
RankRankRankRankRankRankRank
Total Posts:  23522
Joined  05-20-2002

Look forward to seeing the write-up!  Are you still teasing things out- or am I good to go ahead and close the thread?

 Signature 

AKA rob1

Help Request TipsPro Network

Profile
 
 
Posted: 06 July 2008 10:52 AM   [ Ignore ]   [ # 12 ]  
Grad Student
Avatar
Rank
Total Posts:  51
Joined  03-27-2007

I’m still busy, the only thing i didn’t find that quickly is how to remove the throttling in the admin panel as described. Using JQuery now and so it’s browser compatible. You can close the thread. Thanks.

 Signature 

Greate | Zwolle, The Netherlands | Photography · Design · Complete

Profile
 
 
Posted: 08 July 2008 09:26 AM   [ Ignore ]   [ # 13 ]  
Moderator
Avatar
RankRankRankRankRankRankRank
Total Posts:  23522
Joined  05-20-2002

Good deal- and done!

 Signature 

AKA rob1

Help Request TipsPro Network

Profile
 
 
   
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 1149, on July 16, 2007 09:33 AM
Total Registered Members: 64915 Total Logged-in Users: 26
Total Topics: 81870 Total Anonymous Users: 20
Total Replies: 440150 Total Guests: 162
Total Posts: 522020    
Members ( View Memberlist )
Newest Members:  Suman KumarsmilepolitelyrvmcleodbjmohrAqua193Bios Elementmjpoteetguimogranwelshmrcf