DVLP / signalr-no-jquery

120 stars 77 forks source link

invoke to call the server methods #18

Closed zdh8675 closed 4 years ago

zdh8675 commented 7 years ago

image

I have already specified here { jsonp: true },

and then use this code to call the server method:

hubProxy.invoke('joinGroupAsync', { groupName: 'GroupBaoJing' })

but reported the following error:

image

I used C # to write Signalr's self-hosted service, and also added the code to allow cross-domain, but it did not work.

So,I really do not know how to solve this problem, ask for you help.

zdh8675 commented 7 years ago

Everyone has not encountered any problems about invoke?

gtwilliams03 commented 7 years ago

I have and I think it might be limited to long polling. I had to add this line at line 73 of jQueryShim.js:

if (options.type === 'GET' && options.data.data) options.url += `&data=${options.data.data}`

Can you try that and see if it works for you? When the POST command switches to a GET in long polling, the post body is ignored and you have to put the data into the querystring. (I think)

zdh8675 commented 7 years ago

@gtwilliams03 thank you sir, the error disappear, but I still have problems, it seems that there is no call to the server method.

image

I can not see any 'Console', method not called, something goes wrong?

kamil212 commented 7 years ago

I'm seeing the same error as the original post, as I try to invoke a subscription :(

Edit: Disabled { jsonp: true } and I'm all good now

taylormichels commented 6 years ago

thanks @kamil212 that solved the same issue for me too