Can ajax be used to send POST's to httpin node? simple answer please

i’ve tried using ajax to POST and can get it to work. cross domain errors. looking through the forums seem to suggest it can work, but i can’t understand reply’s.

will agents be the solution? if so i’ll wait…

i want to use ajax to get rid of the “OK” response after POSTing. is there an easy way to do this?

thanks

Yes it can be done, a jQuery based code example is available here. Basically, you attach a custom submit function to a form that has action="/", and then use ajax to post.

Are you using your own webpage as a GUI? And are you using PHP?
Is it possible to post your PHP script if you want us to look at it?

Well, i found out 2 things looking at ejeklint’s example.

  1. the ajax post was always working. i get an origin error, but the data does arrive.
  2. the data had to be sent as a javascript json object, NOT a string structured like a json object.

thanks for your help.
ron

miseim: no php here, I’m totally clueless about it. :slight_smile: It’s only the html page with embedded scripts.

mron: yeah it’s odd that it works in spite of that origin error, but I’m not complaining. :slight_smile: As for the JSON thing, the jQuery call takes care of stringifying the JSON object and using JSON is so much simpler than mangling data into strings. JSON rules!

I really appreciate your work putting that demo page together! Would there be anything preventing one from modifying this code to take range/slider input? I tried to do that but I get a mysterious message saying content[object Object] and can’t seem to trace it

[Object object] is coming from a javascript alert? if so can you breakpoint the script and examine the object contents? Most of the problems I had modifying ejeklint’s example were related to getting a properly formed json object.

My modifications consisted of removing 2 of the 3 form inputs and replacing the other with a range slider. The message shows up under the submit button after I press it, and it appears that nothing is being transmitted. You are probably right about the json formatting, as I didn’t look into that at all yet. I’m trying to transmit only the slider value (0-100), so maybe I’m stumbling on a single value when it expects an array? Bear with me; I’m very new to programming anything except CNC machines. Which is a little different!

atherinl,

Can you “table this” (don’t work on it) until the new agents are released to public?
Those new agents will really help with what you’re doing.

I envision your website page (with the slider) will POST a slider value whenever there is a change to it (javascript on change). The imp is always ready to act when a post comes in. With AJAX, you won’t need a submit button either. You can build a GUI on your web page that is dynamic. Any change to any of the buttons or sliders will immediately post to the imp.

mlseim,
I am really looking forward to that functionality! The slider submit button is far from ideal. Is there any timetable for the release?

Oops, sorry for not replying - i hadn’t “starred” this thread. Are you up and running now? And I support the idea to wait for agents - makes a world of difference. :slight_smile:

As for sliders, no need for submit. Have a look at this nice example, it’s even made for colours! :slight_smile:

I’m not up and running yet, but thank you for the link. Agents are (allegedly) so close that it’s making more sense to wait, but if there are two more weeks without I’m sure I’ll be back at it.

@atherinl - you can always email and ask for agent access if you want to try them out now…